From 318e40799e31edbdac6266c09f01f76be1a40c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <gerhard.braeunlich@id.ethz.ch> Date: Mon, 1 Mar 2021 12:56:40 +0100 Subject: [PATCH 1/7] common/mpiutilities.h: Change vector of vector to vector --- src/common/mpiutilities.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/mpiutilities.h b/src/common/mpiutilities.h index 8d03c7416..0c0f96587 100644 --- a/src/common/mpiutilities.h +++ b/src/common/mpiutilities.h @@ -487,11 +487,11 @@ void MPIExchangeBuffers_NonBlocking(vector<vector<T>> _sndT, int idx_recv_tag = 99; int p; - vector<MPI_Request> mpi_send_requests[_sending_procs.size()]; - vector<MPI_Request> mpi_recv_requests[_receiving_procs.size()]; + vector<MPI_Request> mpi_send_requests(_sending_procs.size()); + vector<MPI_Request> mpi_recv_requests(_receiving_procs.size()); - vector<MPI_Status> mpi_send_status[_sending_procs.size()]; - vector<MPI_Status> mpi_recv_status[_receiving_procs.size()]; + vector<MPI_Status> mpi_send_status(_sending_procs.size()); + vector<MPI_Status> mpi_recv_status(_receiving_procs.size()); // MPI_Request *mpi_send_requests; // MPI_Request *mpi_recv_requests; @@ -524,8 +524,8 @@ void MPIExchangeBuffers_NonBlocking(vector<vector<T>> _sndT, // MPI_Waitany(_sending_procs.size(), mpi_send_requests, // &IDX_REQ, mpi_send_status); // } - MPI_Waitall(_sending_procs.size(), &(mpi_send_requests[0]), - &(mpi_send_status[0])); + MPI_Waitall(_sending_procs.size(), &mpi_send_requests[0], + &mpi_send_status[0]); // for(int i_proc=0;i_proc<_receiving_procs.size();i_proc++) // { @@ -890,4 +890,4 @@ void BoostMPIExchange_T_NonBlockingArchive(vector<T> _send_buff, mpi::wait_all(mpi_recv_requests.begin(), mpi_recv_requests.end()); } -} // namespace mpi_utilities \ No newline at end of file +} // namespace mpi_utilities -- GitLab From efc67582251338d017f7511c0fa4ef383cedfa5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <gerhard.braeunlich@id.ethz.ch> Date: Mon, 1 Mar 2021 12:57:43 +0100 Subject: [PATCH 2/7] mesh/removeEdge.ipp: Add include --- src/mesh/removeEdge.ipp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/removeEdge.ipp b/src/mesh/removeEdge.ipp index 243e44655..6f2dec3f0 100644 --- a/src/mesh/removeEdge.ipp +++ b/src/mesh/removeEdge.ipp @@ -1,5 +1,6 @@ #pragma once +#include "removeEdge.h" namespace meshing { inline bool EdgeEraser_3::solve(const double &_volume, @@ -216,4 +217,4 @@ inline double EdgeEraser_3::computeVolume(int i) const { tet = {{source_, target_, ring_[i], ring_[i + 1]}}; return abs(simplexVolume<3>(tet)); } -} // namespace meshing \ No newline at end of file +} // namespace meshing -- GitLab From 14b0dec533f4baeefde8103f508e441b1e2e9ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <gerhard.braeunlich@id.ethz.ch> Date: Mon, 1 Mar 2021 12:58:44 +0100 Subject: [PATCH 3/7] mesh/qcEdgeRemoval.ipp: remove outcommented code --- src/mesh/qcEdgeRemoval.ipp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/mesh/qcEdgeRemoval.ipp b/src/mesh/qcEdgeRemoval.ipp index f7c75429e..5cf623774 100644 --- a/src/mesh/qcEdgeRemoval.ipp +++ b/src/mesh/qcEdgeRemoval.ipp @@ -277,24 +277,6 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: for (const auto &key : _elementsToBeRemoved) { Base::disconnectElement(key); - // for(int d=0; d<4; d++) - // { - // neighbourKey = Base::getSimplexFaceNeighbour(key, d); - - // if(neighbourKey.first!=-1) - // { - // assert(Base::meshCells_.find(neighbourKey.second)!=Base::meshCells_.end()); - - // nid = Base::getMirrorIndex(key, d); - - // if(Base::meshCells_.find(neighbourKey.second)!=Base::meshCells_.end()) - // { - // Base::meshCells_.at(neighbourKey.second).setNeighbour( - // make_pair(-1, - // numeric_limits<size_t>::max()), nid); - // } - // } - // } } return true; } @@ -679,4 +661,4 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: return edgeRemovalSolve; } -} // namespace meshing \ No newline at end of file +} // namespace meshing -- GitLab From f3d0c12e2a78b42c5706655161be02dca84eb0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <gerhard.braeunlich@id.ethz.ch> Date: Fri, 5 Mar 2021 13:54:16 +0100 Subject: [PATCH 4/7] remove obsolete neighbourhoods::InitializeOverlappingMeshElements --- src/neighbourhoods/neighbourhoods.h | 10 - .../overlappingMeshExchange.ipp | 456 +----------------- 2 files changed, 3 insertions(+), 463 deletions(-) diff --git a/src/neighbourhoods/neighbourhoods.h b/src/neighbourhoods/neighbourhoods.h index 001ac7792..1169696dc 100644 --- a/src/neighbourhoods/neighbourhoods.h +++ b/src/neighbourhoods/neighbourhoods.h @@ -43,16 +43,6 @@ void UpdateNeighbourhoodsAllSamplingAtoms( // exchanging and updating nearby mesh elements // MeshElementExchange.ipp -// send and receive elements(submesh) from other ranks -// store the element indices sent and to which processors -template <typename mesh, typename sampling_atom, typename repatom, int DIM> -void InitializeOverlappingMeshElements( - mesh &_local_mesh, - const vector<geom::Ball<double, DIM>> &_sampling_atom_balls, - const vector<int> &_interproc_flags, const int &_noof_interproc_balls, - const vector<repatom> &_local_repatoms, - const Box<point<DIM>, DIM> &_domain_bounds); - template <typename mesh, typename sampling_atom, typename repatom, typename filewriter, int DIM, int NIDOF> void initializeAllNeighbourhoodsAddForces( diff --git a/src/neighbourhoods/overlappingMeshExchange.ipp b/src/neighbourhoods/overlappingMeshExchange.ipp index cc2142497..59f9f1527 100644 --- a/src/neighbourhoods/overlappingMeshExchange.ipp +++ b/src/neighbourhoods/overlappingMeshExchange.ipp @@ -7,461 +7,11 @@ */ #pragma once - +#include "neighbourhoods.h" #include <uniquePointContainer.h> using namespace geometry; -//! Exchange overlapping elements -/*! - this function should make sure to get the mesh required for each - sampling atom that "outreaches". Its very important for this function to - be lite and fool proof. - Communications are heavy initially, since we have to send bravais - vectors and flags as well. Later on, - 1. if we have no remeshing/refining events - and neighbour recalculations, only send node locations - and regenerate new bravais vectors. - - 2. If we have neighbour updates requiring more mesh, - only get new elements, their data, and nodes if required. - These new elements and new nodes indices should be appended - in the exisitng list of sent simplex idxs and sent node idxs -*/ - -/*!This function intializes -_local_mesh.overlappingMeshData.overlap_simplex_idxs_[proc] -> simplex idxs sent -to proc from current rank - -_local_mesh.overlappingMeshData.overlap_node_idxs_[proc] -> nodes sent to proc - -_local_mesh.overlappingMeshData.overlapping_nodes_recv_[proc] ->nodes recvd from -proc - -_local_mesh.overlappingMeshData.overlapping_simplices_recv_[proc] -> simplices -received from proc - -_local_mesh.overlappingMeshData.overlapping_element_lattice_vectors_recv_[proc] --> lattice vectors of recvd simplices from proc - -_local_mesh.overlappingMeshData.overlapping_simplices_recv_atomistic_flag_[proc] --> atomistic flags of the recvf simplices from proc -*/ -template <typename mesh, typename sampling_atom, typename repatomContainer, - int DIM> -void neighbourhoods::InitializeOverlappingMeshElements( - mesh &_local_mesh, - const vector<geom::Ball<double, DIM>> &_interproc_atom_balls, - const vector<int> &_interproc_sampling_atom_flags, - const int &noof_interproc_sampling_atoms, - const repatomContainer &_local_repatom_container, - // const set<size_t> &_idx_interproc_sampling_atoms, - const Box<point<DIM>, DIM> &_domain_bounds) { - - typedef point<DIM> Point; - typedef array<point<DIM>, DIM + 1> Simplex; - typedef Eigen::Matrix<double, DIM, DIM> Matrix; - typedef geom::Ball<double, DIM> ball; - typedef uniquePointContainer<Point, DIM> UniqueContainer; - - vector<int> noof_interproc_balls_data(mpi_size, 0); - vector<double> balls_data_to_bcast; - - timer balls_exchange_clock; - - balls_exchange_clock.tic(); - - balls_data_to_bcast.reserve(noof_interproc_sampling_atoms * (DIM + 1)); - // prepare balls to broadcast - for (size_t i = 0; i < _interproc_atom_balls.size(); i++) { - if (_interproc_sampling_atom_flags[i]) { - for (int d = 0; d < DIM; d++) { - balls_data_to_bcast.push_back(_interproc_atom_balls[i].center[d]); - } - balls_data_to_bcast.push_back(_interproc_atom_balls[i].radius); - } - } - // for(const size_t &atom_idx : _idx_interproc_sampling_atoms) - // { - // for(int d=0; d<DIM; d++) - // { - // balls_data_to_bcast.push_back( - // _interproc_atom_balls[atom_idx].location_[d]); - // } - // balls_data_to_bcast.push_back( - // _interproc_atom_balls[atom_idx].r_cut+VerletBuffer); - // } - - // all-gather amount of interproc balls-data to exchange - mpi_utilities::ALLGATHER<int>(noof_interproc_sampling_atoms, - noof_interproc_balls_data, DIM + 1); - - // vanilla MPI (use all_gatherv with open-mpi) - - // first compute the displacements from _N - vector<int> displacements(mpi_size, 0); - for (int i_rank = 1; i_rank != mpi_size; ++i_rank) { - displacements[i_rank] = - displacements[i_rank - 1] + noof_interproc_balls_data[i_rank - 1]; - } - // if data is in a vector// - // -----------------------------------------------------------------// - // | - // | - // <-noof_data[r]-> - // | | - // <-displacement[r]--> - - vector<double> balls_data_all_proc(displacements[mpi_size - 1] + - noof_interproc_balls_data[mpi_size - 1]); - - // all gather will not work in case - // billions of sampling atoms are sending data - mpi_utilities::ALLGATHERV<double>(balls_data_to_bcast, balls_data_all_proc, - noof_interproc_balls_data, displacements); - - balls_exchange_clock.toc(); - - // // boost::MPI (use boost all_gather) - // vector<vector<double>> balls_data_all_proc_boost; - // mpi::all_gather(world, balls_data_to_bcast, balls_data_all_proc_boost); - // // all-gather interproc balls - - //=-=-=-=-=-=-=-=-= PERFORMANCE NOTES -=-=-=-=-=-=-=-=-=-// - // both open-mpi and boost mpi give similar performance. // - // primary bottle-neck till here is look up of elements // - // and balls that overlap elements - // // - //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// - - // 1. build relevant balls from other processors, and send elements - // 2. store local elements that were sent, along with processors that - // were sent to - - /*! Build 1D vector of all the balls to make an ORQ. - Use displacements for getting which processor index. - */ - /*! We already know the size of all balls to receive */ - - vector<int> ball_procs_delimiters(mpi_size + 1, 0); - for (int i = 0; i < mpi_size; i++) { - ball_procs_delimiters[i + 1] = - displacements[i] / (DIM + 1) + noof_interproc_balls_data[i] / (DIM + 1); - } - - vector<geom::Ball<double, DIM>> balls_all_proc; - balls_all_proc.reserve(balls_data_all_proc.size() / (DIM + 1)); - - vector<vector<int>> ranks_of_unique_balls; - ranks_of_unique_balls.reserve(balls_data_all_proc.size() / (DIM + 1)); - - size_t noof_balls_all_proc = balls_data_all_proc.size() / (DIM + 1); - - UniqueContainer unique_balls(_domain_bounds.lower_, _domain_bounds.upper_); - unique_balls.reserve(noof_balls_all_proc); - - ball interproc_ball; - - int ball_data_ctr = 0; - bool added; - int unique_ball_idx, ball_rank; - - for (int ball_ctr = 0; ball_ctr < noof_balls_all_proc; ball_ctr++) { - const vector<int>::const_iterator it = upper_bound( - ball_procs_delimiters.cbegin(), ball_procs_delimiters.cend(), ball_ctr); - ball_rank = distance(ball_procs_delimiters.cbegin(), it) - 1; - - for (int d = 0; d < DIM; d++) { - interproc_ball.center[d] = balls_data_all_proc[ball_data_ctr]; - ball_data_ctr++; - } - - interproc_ball.radius = balls_data_all_proc[ball_data_ctr]; - ball_data_ctr++; - - added = unique_balls.push_back(interproc_ball.center, unique_ball_idx); - - if (added) { - balls_all_proc.push_back(interproc_ball); - ranks_of_unique_balls.push_back(vector<int>{ball_rank}); - } else { - ranks_of_unique_balls[unique_ball_idx].push_back(ball_rank); - } - } - - // for(int ball_ctr=0; ball_ctr<balls_all_proc.size(); ball_ctr++) - // { - // for(int d=0; d<DIM; d++){ - // interproc_ball.center[d] = balls_data_all_proc[ball_data_ctr]; - // ball_data_ctr++; - // } - // interproc_ball.radius = balls_data_all_proc[ball_data_ctr]; - // balls_all_proc[ball_ctr] = interproc_ball; - // ball_data_ctr++; - // } - - //=-=-=-=- Build a tree once for all the received balls-=-=-=-=-// - // get the elements that intersect other's balls (not our own) - // Try to make sure that the balls are mostly unique. If the KDTree - // fails, then the leafsize of KDTree needs to be increased. Will happen - // if too many points are being repeated. We need the unique container! - - geom::IntersectionQuerySimplexBalls<DIM, double, geom::KDTree> - interproc_ball_simplex_query(balls_all_proc.begin(), - balls_all_proc.end()); - - vector<int> idxs_balls_overlapping; - idxs_balls_overlapping.reserve(int(balls_all_proc.size() / mpi_size)); - - Simplex simplex; - - for (int i_el = 0; i_el != _local_mesh.meshCells_.size(); i_el++) { - _local_mesh.getSimplex(i_el, simplex); - - idxs_balls_overlapping.clear(); - - interproc_ball_simplex_query.query(back_inserter(idxs_balls_overlapping), - simplex); // back inserter in std - - for (const int &idx_ball : idxs_balls_overlapping) { - // const vector<int>::const_iterator it = - // upper_bound(ball_procs_delimiters.cbegin(), - // ball_procs_delimiters.cend(), idx_ball); - - // ball_rank = distance(ball_procs_delimiters.cbegin(), it) - 1; - - // add omp with locks later - //(https://computing.llnl.gov/tutorials/openMP/#OMP_SET_LOCK) - for (const int &unique_ball_rank : ranks_of_unique_balls[idx_ball]) { - // need to mark if this element has been sent to unique_ball_rank - if (!_local_mesh.overlappingMeshData - .overlap_simplex_idxs_sent_flag_[unique_ball_rank][i_el]) { - _local_mesh.overlappingMeshData - .overlap_simplex_idxs_sent_flag_[unique_ball_rank][i_el] = true; - _local_mesh.overlappingMeshData - .overlap_simplex_idxs_[unique_ball_rank] - .push_back(i_el); - -#ifdef DISPLAY_ELEMENT_MARKERS - _local_mesh.element_markers_[i_el] = 10.0; -#endif - } - } - } - } - - // now we have simplex ids that need to be sent. We have to send - // one by one and receive, with traditional non-blocking MPI_Isend - // data to be sent is nodes (coordinates), lattice vectors, - // atomistic flags. - vector<vector<double>> all_send_double_data(mpi_size); - vector<vector<int>> all_send_int_data(mpi_size); - - vector<int> noof_simplices_send(mpi_size, 0); - vector<int> noof_nodes_send(mpi_size, 0); - - vector<double> meshnodes_send; - meshnodes_send.reserve(_local_mesh.meshNodes_.size() * DIM); - - vector<bool> added_nodes(_local_mesh.meshNodes_.size(), false); - vector<int> added_nodes_local_indices(_local_mesh.meshNodes_.size(), - numeric_limits<int>::max()); - - array<int, DIM + 1> indexed_simplex; - - for (int i_proc = 0; i_proc < mpi_size; i_proc++) { - if (i_proc != mpi_rank) { - // meshdata_send.clear(); - - fill(added_nodes.begin(), added_nodes.end(), false); - - fill(added_nodes_local_indices.begin(), added_nodes_local_indices.end(), - numeric_limits<int>::max()); - - noof_simplices_send[i_proc] = - _local_mesh.overlappingMeshData.overlap_simplex_idxs_[i_proc].size(); - - _local_mesh.overlappingMeshData.overlap_node_idxs_[i_proc].reserve( - _local_mesh.meshNodes_.size()); - - all_send_double_data[i_proc].reserve(noof_simplices_send[i_proc] * - (DIM * DIM) + - _local_mesh.meshNodes_.size() * DIM); - - all_send_int_data[i_proc].reserve(noof_simplices_send[i_proc] * - (DIM + 1 + 1)); - - meshnodes_send.clear(); - - for (const int idx : - _local_mesh.overlappingMeshData.overlap_simplex_idxs_[i_proc]) { - for (int d = 0; d < DIM + 1; d++) { - if (!added_nodes[_local_mesh.simplices_[idx][d]]) { - added_nodes[_local_mesh.simplices_[idx][d]] = true; - - for (int l = 0; l < DIM; l++) { - // DIM number of coordinates - meshnodes_send.push_back( - _local_mesh.nodes_[_local_mesh.simplices_[idx][d]][l]); - } - - // we recieve back forces in this order and just add to these - // repatoms - // _local_mesh.overlappingMeshData.overlap_node_idxs_[i_proc].insert( - // _local_mesh.simplices_[idx][d]); - _local_mesh.overlappingMeshData.overlap_node_idxs_[i_proc] - .push_back(_local_mesh.simplices_[idx][d]); - - added_nodes_local_indices[_local_mesh.simplices_[idx][d]] = - noof_nodes_send[i_proc]; - - noof_nodes_send[i_proc]++; - } - // DIM+1 number of vertex indices - all_send_int_data[i_proc].push_back( - added_nodes_local_indices[_local_mesh.simplices_[idx][d]]); - } - - all_send_int_data[i_proc].push_back( - _local_mesh.element_atomistic_flag_[idx]); - - // DIM*DIM lattice vector components - for (int m = 0; m < DIM; m++) { - for (int n = 0; n < DIM; n++) { - all_send_double_data[i_proc].push_back( - _local_mesh.element_lattice_vectors_[idx](m, n)); - } - } - } - - all_send_double_data[i_proc].insert( - all_send_double_data[i_proc].end(), - make_move_iterator(meshnodes_send.begin()), - make_move_iterator(meshnodes_send.end())); - } - } - - // free the memory - vector<double>().swap(meshnodes_send); - - vector<int> noof_simplices_recv(mpi_size, 0); - vector<int> noof_nodes_recv(mpi_size, 0); - - mpi_utilities::MPIExchangeBuffers_NonBlocking<int>( - noof_simplices_send, noof_simplices_recv, mpi_size); - mpi_utilities::MPIExchangeBuffers_NonBlocking<int>(noof_nodes_send, - noof_nodes_recv, mpi_size); - - vector<vector<double>> all_recv_double_data(mpi_size); - vector<vector<int>> all_recv_int_data(mpi_size); - for (int i = 0; i < mpi_size; i++) { - all_recv_double_data[i].resize((DIM * DIM) * noof_simplices_recv[i] + - (DIM)*noof_nodes_recv[i]); - - all_recv_int_data[i].resize((DIM + 1 + 1) * noof_simplices_recv[i]); - } - - mpi_utilities::MPIExchangeBuffers_NonBlocking<int>( - all_send_int_data, all_recv_int_data, mpi_size); - - mpi_utilities::MPIExchangeBuffers_NonBlocking<double>( - all_send_double_data, all_recv_double_data, mpi_size); - - // 04/05/2020 we have to store mapping of boundary nodes to new received - // nodes, - // AND new received nodes from a given rank to received nodes from other ranks - // Some vertices may have multiple images in a given rank. We have to access - // all these images. - - // 07/05/2020. Actually, no we don't need these mappings. - // A given repatom r has force (s,n) from s sampling atom and n neighbour. - // we add r(s_my, n_my) and r(s_o, n_my). And then let the interproc nodes - // communicate forces. When they send their own (s_my, n_my) and r(s_o, n_my), - // those are, r(s_o, n_o) and r(s_my, n_o) for connected nodes - // IF WE ARE ADDING UNIQUE NEIGHBOURS, Then no contributions from interproc - // neighbours will be added. We only have to divide the contributions of - // interproc sampling atoms by their multiplicity. - - // 07/10/2020. Hahahahaha great Speed Dr. Gupta! You fuckin idiot! - // we dont't need to divide the contributions of interproc sampling atoms, - // if don't do the work on interproc sampling atoms. Since PETSC forced - // to have a ghost-global structure of nodes, we only work with strictly local - // sampling atoms. - - // when we have to do this for a given atom, only send - // simplices not already sent to the rank - int simplex_data_offset; - - array<size_t, DIM + 1> recv_simplex; - Point recv_node; - Matrix recv_matrix; - - for (int i_proc = 0; i_proc < mpi_size; i_proc++) { - if (i_proc != mpi_rank) { - - _local_mesh.overlappingMeshData - .overlapping_element_lattice_vectors_recv_[i_proc] - .reserve(noof_simplices_recv[i_proc]); - - _local_mesh.overlappingMeshData.overlapping_simplices_recv_[i_proc] - .reserve(noof_simplices_recv[i_proc]); - - for (int i_el_recv = 0; i_el_recv < noof_simplices_recv[i_proc]; - i_el_recv++) { - for (int d = 0; d < DIM; d++) { - for (int l = 0; l < DIM; l++) { - recv_matrix(d, l) = - all_recv_double_data[i_proc] - [DIM * DIM * i_el_recv + d * DIM + l]; - } - } - - _local_mesh.overlappingMeshData - .overlapping_element_lattice_vectors_recv_[i_proc] - .push_back(recv_matrix); - - for (int d = 0; d < DIM + 1; d++) { - recv_simplex[d] = - all_recv_int_data[i_proc][(DIM + 1 + 1) * i_el_recv + d]; - } - - _local_mesh.overlappingMeshData.overlapping_simplices_recv_[i_proc] - .push_back(recv_simplex); - - _local_mesh.overlappingMeshData - .overlapping_simplices_recv_atomistic_flag_[i_proc] - .push_back( - all_recv_int_data[i_proc][(DIM + 1 + 1) * i_el_recv + DIM + 1]); - } - - simplex_data_offset = DIM * DIM * noof_simplices_recv[i_proc]; - _local_mesh.overlappingMeshData.overlapping_nodes_recv_[i_proc].reserve( - noof_nodes_recv[i_proc]); - - for (int ind_recv = 0; ind_recv < noof_nodes_recv[i_proc]; ind_recv++) { - for (int d = 0; d < DIM; d++) { - recv_node[d] = all_recv_double_data[i_proc][simplex_data_offset + - DIM * ind_recv + d]; - } - - _local_mesh.overlappingMeshData.overlapping_nodes_recv_[i_proc] - .push_back(recv_node); - } - } - } - - // we have the required data for communication. - - // at each iteration - // (with no update in neighbourhoods), we communicate the new locations of - // submesh nodes only. For change in neighbourhoods, we send - // new simplices set. At the receiving end, we send only a new simplex - // its data, and its nodes, if not already sent. - - // cout<<"rank "<<mpi_rank<<"took "<<balls_exchange_clock.elapsed_time_<<" - // seconds"<<endl; -} - template <typename mesh, int DIM, int NIDOF> void neighbourhoods::updateOverlappingMeshElementsAndNodes( mesh &_local_mesh, @@ -555,7 +105,7 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( bool added; int unique_ball_idx, ball_rank; - for (int ball_ctr = 0; ball_ctr < noof_balls_all_proc; ball_ctr++) { + for (size_t ball_ctr = 0; ball_ctr < noof_balls_all_proc; ball_ctr++) { const vector<int>::const_iterator it = upper_bound( ball_procs_delimiters.cbegin(), ball_procs_delimiters.cend(), ball_ctr); ball_rank = distance(ball_procs_delimiters.cbegin(), it) - 1; @@ -987,4 +537,4 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( vector<size_t>().swap(added_simplex_idxs_for_sending[i_proc]); vector<size_t>().swap(added_node_idxs_for_sending[i_proc]); } -} \ No newline at end of file +} -- GitLab From 161f339d01af5ce441ecf1ba0027a8c22ba9cc86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <gerhard.braeunlich@id.ethz.ch> Date: Fri, 5 Mar 2021 13:54:46 +0100 Subject: [PATCH 5/7] Update podman instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb48053de..89e9dbf3a 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ owned by root, outside they will be owned by the host OS user. Run: ```bash -podman run -it --rm -v .:/work qc +podman run -it --rm -v .:/work --user $(id --user) --userns=keep-id qc ``` Here, podman also allows to mount `.` (you dont need the `"$(pwd)"`). -- GitLab From c5f02aea385d9b38c8c5a61eaef072e4e9b0a86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <gerhard.braeunlich@id.ethz.ch> Date: Sat, 6 Mar 2021 13:03:53 +0100 Subject: [PATCH 6/7] remove google/dense_hash_map --- src/common/StandardHeaders.h | 5 - src/mesh/qcMesh.h | 2 - src/preprocessor/mesher.h | 427 ----------------------------------- 3 files changed, 434 deletions(-) delete mode 100644 src/preprocessor/mesher.h diff --git a/src/common/StandardHeaders.h b/src/common/StandardHeaders.h index cfd5c5c7a..736179008 100644 --- a/src/common/StandardHeaders.h +++ b/src/common/StandardHeaders.h @@ -101,11 +101,6 @@ extern "C" { *************************************************/ #include <gsl/gsl_spline.h> -/********************************************/ /** - * google dense hash map - *************************************************/ -#include <google/dense_hash_map> - /********************************************/ /** * OLD STLIB like stuff (VITAL *for computational geometry) To diff --git a/src/mesh/qcMesh.h b/src/mesh/qcMesh.h index 15b359939..8f5d42039 100644 --- a/src/mesh/qcMesh.h +++ b/src/mesh/qcMesh.h @@ -2,8 +2,6 @@ #include "mesh.h" -using google::dense_hash_map; - namespace meshing { template <int D, int K, int NIDOF> struct InterProcMeshData { public: diff --git a/src/preprocessor/mesher.h b/src/preprocessor/mesher.h deleted file mode 100644 index 32a911248..000000000 --- a/src/preprocessor/mesher.h +++ /dev/null @@ -1,427 +0,0 @@ -#pragma once - -#include <iostream> -#include <vector> - -#include "material.h" -#include "mpi_var.h" -#include "variables.h" - -#include "StandardHeaders.h" -#include "array_ext.h" -#include "box.h" -#include "lattice.h" -#include "material.h" -#include "mesh.h" -#include "mpi_var.h" -#include "point.h" -#include "qcMesh.h" -#include "repatomcontainer.h" -#include "repatoms.h" -#include "samplingatoms.h" -#include "variables.h" - -#include "parmetis.h" -#include "vtkIO.h" - -#include "pnetIO.h" -#include "triangulationToMesh.h" - -typedef ExtendedFinnisSinclairCopper<DIM> Copper; -typedef point<DIM> point_d; -typedef Box<point_d, DIM> box_d; -typedef lattice::Lattice<point_d, DIM> lattice_d; -typedef pair<int, int> edge_d; - -// if KSimplexDMesh template takes DIM, DIM --> this is correct! -// if KSimplexDMesh takes another argument than DIM these have to be changed -// too! Same for _ind_simplex - -typedef array<size_t, DIM + 1> _ind_simplex_; - -typedef point<DIM> _node_; -typedef array<_node_, DIM + 1> _simplex_; - -typedef meshing::simplexCell<DIM, DIM> _simplexCell_; -typedef meshing::node<DIM> _simplexNode_; - -using namespace std; - -template <typename mesh_d, typename qc_mesh_d, int DIM> class mesher { - -public: - mesher() { - x_max = 500.0; - x_min = -500.0; - y_max = 700.0; - y_min = 0.0; - z_max = 250.0; - z_min = -250.0; - n_coarsening_levels = 1; - coarsening_factor = 4.0; - atomistic_domain_x = 4.0; - initial_level = 1.0; - N_zones = 6; - n_sub_lattice_ = 1; - materials_.resize(n_sub_lattice_); - materials_[0] = new Copper; - materials_[0]->AssignBasisVectors(); - } - - void buildAndOutputMesh() { - // generate mesh - lattice_d lattice = generateLattice(); - - qc_mesh_d local_mesh = generateMeshFromLattice(lattice); - - // write .vtu - // output::WriteVTUMesh3D<qc_mesh_d>(local_mesh); - - // write .nc - restart::WriteMeshParallel<qc_mesh_d, DIM>(local_mesh); - } - - // argument of file name which we have to read - // string input file - void readAndRedistributeMesh() { - qc_mesh_d read_local_mesh; - - vector<int> _cell_data_to_read; - - vector<double> _node_data_to_read; - - // pass the file name - restart::ReadCellsParallel<DIM>(_cell_data_to_read); - - restart::ReadNodesParallel<DIM>(_node_data_to_read); - - // meshNodes_ has the needed nodes according to the cells - read_local_mesh.build(_cell_data_to_read, _node_data_to_read); - - read_local_mesh.buildIndexKeyMaps(); - - read_local_mesh.buildMeshTopology(); - - read_local_mesh.trim(domain_bounds_); - - read_local_mesh.renumberCells(); - - // this function tells which nodes are connected to which processor - read_local_mesh.buildInterprocConnectivity(); - - read_local_mesh.redistributeMesh(); - } - -private: - int n_sub_lattice_; - double x_char_; - box_d domain_bounds_; - vector<material<DIM> *> materials_; - - lattice_d generateLattice() { - x_char_ = materials_[0]->BasisVectors[0][0]; - - lattice_d lattice = - lattice::Lattice<point_d, DIM>(n_sub_lattice_, materials_); - - point_d lattice_center = {{0, 0, 0}}; - - lattice.AssignBasisVectors(materials_); - - atomistic_domain_x = atomistic_domain_x * x_char_; - - vector<double> coarsening_levels_domains(n_coarsening_levels); - - for (int i = 0; i < n_coarsening_levels; i++) { - coarsening_levels_domains[i] = - atomistic_domain_x + 2.0 * double(i) * (atomistic_domain_x); - } - - vector<box_d> coarsening_levels(n_coarsening_levels + 1); - - double expansion = 1.0; - - point_d upper, lower; - array<double, DIM> translation_coordinates; - translation_coordinates.fill(0.0); - - for (int i_box = 0; i_box < n_coarsening_levels; i_box++) { - upper = lattice_center + coarsening_levels_domains[i_box]; - lower = lattice_center - coarsening_levels_domains[i_box]; - translation_coordinates[DIM - 1] = upper[DIM - 1]; - upper = upper - translation_coordinates; - lower = lower - translation_coordinates; - coarsening_levels[i_box + 1] = box_d(lower, upper); - } - - point_d domain_upper = {{x_max, y_max, z_max}}; - - point_d domain_lower = {{x_min, y_min, z_min}}; - - domain_bounds_ = box_d(domain_lower, domain_upper); - - // 0th coarsening level is an inverted box - // CreateLatticeSitesInBounds only adds points inside - // a given box AND outside the previous-to-given box - // so, by (inside if lower<point<upper) logic, every point is always - // outside the first rectangle - coarsening_levels[0] = - box_d(coarsening_levels[1].upper_, coarsening_levels[1].lower_); - - vector<point_d> seed_points(1); - - vector<int> boundary_points; - - seed_points[0] = lattice_center; - - vector<vector<double>> adjusted_basis(DIM); - - double coarsening = initial_level; - - for (int i_box = 0; i_box < n_coarsening_levels; i_box++) { - boundary_points.resize(0); - - for (int iv = 0; iv < DIM; iv++) { - adjusted_basis[iv].resize(DIM); - for (int d = 0; d < DIM; d++) { - adjusted_basis[iv][d] = coarsening * lattice.basis[0](d, iv); - // basis are stored as (each column being the vector) - } - } - - lattice::CreateLatticeSitesInBounds<point_d, box_d, DIM>( - coarsening_levels[i_box + 1], coarsening_levels[i_box], seed_points, - adjusted_basis, lattice, boundary_points); - - coarsening *= coarsening_factor; - } - - lattice.bindLatticeSites(domain_bounds_); - - return lattice; - } - - qc_mesh_d generateMeshFromLattice(const lattice_d &_lattice) { - vector<int> material_indices; - mesh_d global_mesh; - qc_mesh_d local_mesh; - - typedef triangulation::Triangulation<DIM> Triangulation_CGAL; - typedef meshing::CGALToMeshConverter<DIM, mesh_d, point_d> - TriangulationToMesh; - - // vector<repatom_d> repatom_container; - vector<CGAL_POINT> repatoms_locations; - TriangulationToMesh TriangulationConverter; - - if (mpi_rank == 0) { - // repatoms::PopulateAllRepatomsLattice<point_d, DIM, NIDOF>(_lattice, - // repatom_container); - lattice::convertLatticeLocations<DIM>(repatoms_locations, - _lattice.lattice_sites); - - material_indices = _lattice.lattice_sites_material_idx; - - Triangulation_CGAL initial_triangulation; - - initial_triangulation.CreateTriangulationOverPoints(repatoms_locations); - - vector<point_d> repatom_locations_point_d; - - ConvertLibPoints2MyPoints<CGAL_POINT, point_d, DIM>( - repatoms_locations, repatom_locations_point_d); - - TriangulationConverter.BuildMeshFromCgalTriangulation( - repatom_locations_point_d, global_mesh, - initial_triangulation.triangulation, material_indices); - } - - mpi_utilities::boostBroadcast<mesh_d>(global_mesh); - - mpi_utilities::boostBroadcast<vector<int>>(material_indices); - - global_mesh.buildIndexKeyMaps(); - - global_mesh.buildMeshTopology(); - - global_mesh.trim(domain_bounds_); - - mesherDistributeMesh(global_mesh, local_mesh, material_indices); - - local_mesh.buildIndexKeyMaps(); - - return local_mesh; - } - - void mesherDistributeMesh(const mesh_d &_global_mesh, qc_mesh_d &_local_mesh, - const vector<int> &_material_idxs) { - int a = DIM; - int adj_edges = 0; - int n_constraint = 1; - int nel_proc; - int wgtflag, numflag; - int n_parts = mpi_size; - int options[3]; - - vector<int> elements_of_ranks; - vector<int> nboel_tmp_i; - vector<int> nboel_tmp_v; - vector<int> vwgt; - vector<int> adjwgt; - vector<int> local_elements; - vector<int> el_part; - vector<float> tpwgts; - vector<float> ubvec; - - MPI_Comm mpi_comm; - MPI_Comm_dup(MPI_COMM_WORLD, &mpi_comm); - - elements_of_ranks.resize(mpi_size + 1); - - calcUniformDist(elements_of_ranks, _global_mesh.meshCells_.size(), - mpi_size); - - nel_proc = elements_of_ranks[mpi_rank + 1] - elements_of_ranks[mpi_rank]; - - adj_edges = buildParmetisGraph<pair<size_t, size_t>>( - nboel_tmp_i, nboel_tmp_v, mpi_size, _global_mesh.faces_.size(), - _global_mesh.if_boundary_faces_, _global_mesh.simplex_index_to_key_, - elements_of_ranks, nel_proc, _global_mesh.faces_, mpi_rank); - - vwgt.reserve(nel_proc); - for (int i = 0; i < nel_proc; i++) - vwgt.push_back(1); - - adjwgt.reserve(adj_edges); - for (int i = 0; i < adj_edges; i++) - adjwgt.push_back(1); - - wgtflag = 0; - numflag = 0; - - tpwgts.reserve(n_constraint * n_parts); - ubvec.reserve(n_constraint); - - ubvec.push_back(1.01); - - options[0] = 1; // 0: following 2 options are skipped, - // 1: use following options - options[1] = 3; // print more timing info: default: 0 - options[2] = 15; // random seed, default: 15 - - int edgecut; - for (int i = 0; i < n_parts; i++) { - for (int j = 0; j < n_constraint; j++) { - tpwgts.push_back(1.0 / float(n_parts)); - } - } - - el_part.resize(nel_proc); - - if (mpi_rank == 0) - cout << " PARAMETIS OUTPUT " << endl; - - ParMETIS_V3_PartKway(&elements_of_ranks[0], &nboel_tmp_i[0], - &nboel_tmp_v[0], &vwgt[0], &adjwgt[0], &wgtflag, - &numflag, &n_constraint, &n_parts, &tpwgts[0], - &ubvec[0], options, &edgecut, &el_part[0], &mpi_comm); - - vector<int> ranks_of_elements; - - RedistributeGraph(elements_of_ranks, el_part, local_elements, - ranks_of_elements, _global_mesh.meshCells_.size(), - nel_proc, mpi_size, mpi_rank); - - // every repartitioning needs face neighbours across ranks. - // We have our own simplices. And we can get vertices of - // our own simplices. - // We require common vertices and all incidences - // on those common vertices. - - // If we assume no connectivity to start with, then - // we have to merge vertices using octree and then proceed. - - // renumbers mesh so nodes are arranged in an order - // _local_mesh.buildSubMeshFromSubset(local_elements, - // ranks_of_elements, _material_idxs, - // mpi_rank, mpi_size, _global_mesh); - - mesherbuildSubMeshFromSubset(local_elements, ranks_of_elements, - _material_idxs, mpi_rank, mpi_size, - _global_mesh, _local_mesh); - } - - void mesherbuildSubMeshFromSubset(const vector<int> &_subset_simplex_ids, - // we need ranks of nodes also - const vector<int> &_ranks_of_simplices, - const vector<int> &_node_material_indices, - const int &_owner_rank, - const int &_total_owners, - const mesh_d &_parent_mesh, - qc_mesh_d &_local_mesh) { - /* 1. Build this local mesh - * 2. Build the inter-mesh connectivity - * 3. Exchange the halo mesh elements - * 4. Renumber the mesh node indices, - * so all the ghost indices are at the end, to allow petsc based variables - * 5. - */ - - unordered_map<size_t, bool> added_nodes; - - unordered_map<size_t, size_t> added_nodes_local_indices_; - - _ind_simplex_ simplex; - - _local_mesh.meshNodes_.reserve(_parent_mesh.meshNodes_.size()); - _local_mesh.meshCells_.reserve(_subset_simplex_ids.size()); - - _local_mesh.material_idx_of_nodes_.reserve(_parent_mesh.meshNodes_.size()); - - vector<size_t> localToOldGlobalIndices; - localToOldGlobalIndices.reserve(_parent_mesh.meshNodes_.size()); - - _simplexCell_ cell; - _simplexNode_ node; - - size_t localCellKey, localNodeKey, simplex_key; - - _local_mesh.newCellKey_ = 0; - - _local_mesh.newNodeKey_ = 0; - - // we store the global keys directly! That's the best part of unordered map - // build this local mesh - for (size_t simplex_idx : _subset_simplex_ids) { - simplex_key = _parent_mesh.simplex_index_to_key_[simplex_idx]; - - cell = _parent_mesh.meshCells_.at(simplex_key); - - for (int d = 0; d < DIM + 1; d++) { - if (added_nodes.find(cell[d].second) == added_nodes.end()) { - // added_nodes.at(cell[d].second) = true; - added_nodes.insert(make_pair(cell[d].second, true)); - - node = _parent_mesh.meshNodes_.at(cell[d].second); - - node.setPairKey(make_pair(mpi_rank, cell[d].second)); - - _local_mesh.meshNodes_.insert(make_pair(cell[d].second, node)); - - _local_mesh.material_idx_of_nodes_.push_back( - _node_material_indices[cell[d].second]); - } - - cell.setNode(make_pair(mpi_rank, cell[d].second), d); - } - - cell.setPairKey(make_pair(mpi_rank, simplex_key)); - - _local_mesh.meshCells_.insert(make_pair(simplex_key, cell)); - - if (_local_mesh.newCellKey_ < simplex_key) { - _local_mesh.newCellKey_ = simplex_key; - } - } - } -}; \ No newline at end of file -- GitLab From b9640aeaa32397e2de3a3c3fe80a58643b9facaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <gerhard.braeunlich@id.ethz.ch> Date: Sat, 6 Mar 2021 13:05:37 +0100 Subject: [PATCH 7/7] Remove 'using namespace ...' from headers --- src/boundaryconditions/boundarycondition.h | 40 +- .../externalForceApplicator.h | 15 +- src/boundaryconditions/fixedboundary.h | 35 +- src/boundaryconditions/freeboundary.h | 34 +- src/boundaryconditions/nanoindenter_sphere.h | 50 +-- src/boundaryconditions/nullapplicator.h | 9 +- src/boundaryconditions/slipboundary.h | 36 +- src/boundaryconditions/straight_press.h | 8 +- src/common/Euclidean.h | 231 +++++------ src/common/interpolators.h | 8 +- src/common/mpiutilities.h | 267 +++++++------ src/common/sorters.h | 3 - src/common/utilities.h | 170 ++++---- src/debuggers/debug_interprocatoms.ipp | 53 +-- src/debuggers/debuggers.h | 8 +- src/geometry/mapping.h | 18 +- src/geometry/point.h | 4 +- src/geometry/point.ipp | 33 +- src/geometry/segment.h | 6 +- src/geometry/simplex.h | 32 +- src/geometry/simplex.ipp | 108 +++--- src/geometry/squareMat.h | 5 +- src/input/userinput.h | 29 +- src/lattice/inputLatticeGenerators.h | 4 +- src/lattice/lattice.h | 245 ++++++------ .../NanoIndentation/NanoIndentation.h | 68 ++-- src/lattice/latticeSite.h | 29 +- src/lattice/repatomcontainer.h | 85 ++-- src/lattice/repatoms.h | 88 +++-- src/lattice/samplingatoms.h | 200 +++++----- src/lattice/samplingatomsweightcalculators.h | 2 +- src/lattice/uniqueLatticeSiteContainer.h | 11 +- src/lattice/uniqueLatticeSiteList.h | 15 +- src/materials/copper/copper.h | 23 +- .../copper/copperExtendedFinnisSinclair.h | 117 +++--- src/materials/copper/copperJohnson.h | 115 +++--- src/materials/copper/copperTabulated.h | 96 ++--- src/materials/material.h | 132 ++++--- src/mesh/checkMeshTopologyAndConnectivity.ipp | 7 +- src/mesh/element_tessellators.h | 2 +- src/mesh/gatherHaloMesh.ipp | 132 +++---- src/mesh/mesh.h | 165 ++++---- src/mesh/meshInterprocConnectivity.ipp | 35 +- src/mesh/meshNode.h | 13 +- src/mesh/meshPeriodicConnectivity.ipp | 43 +- src/mesh/meshRepairDependent.ipp | 89 ++--- src/mesh/meshRepairLocal.ipp | 97 ++--- src/mesh/meshSimplexCell.h | 35 +- src/mesh/meshTopology.ipp | 25 +- src/mesh/meshTraversal.ipp | 26 +- src/mesh/meshTrim.ipp | 27 +- src/mesh/meshdistribution.h | 31 +- src/mesh/metisutils.h | 25 +- src/mesh/packNodalData.ipp | 22 +- src/mesh/qcEdgeRemoval.ipp | 125 +++--- src/mesh/qcFaceRemoval.ipp | 32 +- src/mesh/qcMesh.h | 366 +++++++++--------- src/mesh/qcMeshRepair.ipp | 69 ++-- src/mesh/redistributeMesh.ipp | 154 ++++---- src/mesh/redistributeMesh_debug.ipp | 120 +++--- src/mesh/removeEdge.h | 25 +- src/mesh/removeEdge.ipp | 29 +- src/mesh/removeFace.h | 17 +- src/mesh/removeFace.ipp | 6 +- src/mesh/renumberMesh.ipp | 52 +-- src/mesh/subMeshFromSubset.ipp | 36 +- src/mesh/triangulation.h | 69 ++-- src/mesh/triangulationToMesh.h | 10 +- src/mesh/triangulationToMesh.ipp | 31 +- src/mesh/uniformDistributeMesh.ipp | 36 +- src/neighbourhoods/AddForcesToAllRepatoms.ipp | 42 +- .../CalculatePotentialsAndForces.ipp | 51 +-- .../bruteForceNeighbourCheck.ipp | 24 +- src/neighbourhoods/getEntropyRates.ipp | 13 +- src/neighbourhoods/getForceAndPotential.ipp | 115 +++--- .../getRequiredNeighbourhoods.ipp | 134 +++---- src/neighbourhoods/neighbourhoods.h | 64 +-- src/neighbourhoods/neighbourhoods.ipp | 105 ++--- src/neighbourhoods/neighbourhoods_global.h | 212 +++++----- .../overlappingMeshExchange.ipp | 70 ++-- src/neighbourhoods/periodicMeshExchange.ipp | 76 ++-- src/neighbourhoods/uniqueBallContainer.h | 11 +- .../updateAllNeighbourhoods.ipp | 50 ++- src/orq/simplex_distance.h | 1 - src/orq/uniquePointContainer.h | 15 +- src/pnetwriter/ReadMesh.ipp | 14 +- src/pnetwriter/ReadRestart.ipp | 70 ++-- src/pnetwriter/WriteMesh.ipp | 73 ++-- src/pnetwriter/WriteRestart.ipp | 70 ++-- src/pnetwriter/pnetIO.h | 59 +-- src/pnetwriter/rearrangeMeshFromRestart.ipp | 259 +++++++------ src/preStrain/LomerDipole.ipp | 20 +- src/preprocessor/preproc.h | 19 +- src/solver/calculateDeformation.ipp | 57 ++- src/solver/initializer.h | 30 +- src/solver/petscSolver.ipp | 1 + src/solver/solver.h | 93 ++--- src/solver/timeIntegrators.ipp | 100 ++--- src/vtkwriter/vtkIO.h | 130 ++++--- src/vtkwriter/vtkMeshWriters.ipp | 97 ++--- src/vtkwriter/vtkPointDataWriters2D.ipp | 12 +- src/vtkwriter/vtkPointDataWriters3D.ipp | 27 +- 102 files changed, 3310 insertions(+), 3187 deletions(-) diff --git a/src/boundaryconditions/boundarycondition.h b/src/boundaryconditions/boundarycondition.h index 637c9f462..820ab12ca 100644 --- a/src/boundaryconditions/boundarycondition.h +++ b/src/boundaryconditions/boundarycondition.h @@ -7,11 +7,11 @@ template <int DIM> class boundarycondition { public: - vector<int> localrepatomids_; - vector<point<DIM>> bounds_; - array<double, DIM> normal_; - string zone_name_; - string zone_type_; + std::vector<int> localrepatomids_; + std::vector<point<DIM>> bounds_; + std::array<double, DIM> normal_; + std::string zone_name_; + std::string zone_type_; int precedence_order_; int coordinate_; double bound_; @@ -19,30 +19,32 @@ public: virtual void AssignBounds(const point<DIM> &_p1, const point<DIM> &_p2) = 0; virtual void AssignBounds(const point<DIM> &_p1, const point<DIM> &_p2, const point<DIM> &_p3) = 0; - virtual void AssignZoneName(const string &_zone_name) = 0; - virtual void AssignNormal(const array<double, DIM> &_n) = 0; + virtual void AssignZoneName(const std::string &_zone_name) = 0; + virtual void AssignNormal(const std::array<double, DIM> &_n) = 0; virtual bool pointInBoundary(const point<DIM> &_p) = 0; virtual void AddRepAtom(const point<DIM> &_atom_location, const int &_id, const int &_boundary_ctr, bool &_boundary_flag) = 0; - // virtual void Update(vector<point<DIM>> &_atomVelocities)=0; + // virtual void Update(std::vector<point<DIM>> &_atomVelocities)=0; - virtual void Update(const vector<point<DIM>> &_atomLocations, - vector<point<DIM>> &_atomVelocities) = 0; + virtual void Update(const std::vector<point<DIM>> &_atomLocations, + std::vector<point<DIM>> &_atomVelocities) = 0; - virtual void AddError(const vector<point<DIM>> &, const vector<point<DIM>> &, - const vector<double> &, const vector<int> &, + virtual void AddError(const std::vector<point<DIM>> &, + const std::vector<point<DIM>> &, + const std::vector<double> &, const std::vector<int> &, const size_t &, double &, double &) = 0; - virtual void UpdateForces(const vector<point<DIM>> &, - vector<point<DIM>> &_atomForces) = 0; + virtual void UpdateForces(const std::vector<point<DIM>> &, + std::vector<point<DIM>> &_atomForces) = 0; - virtual void AddThermalError(const vector<point<DIM>> &, - const vector<double> &, const vector<double> &, - const vector<int> &, const size_t &, double &, - double &) = 0; + virtual void AddThermalError(const std::vector<point<DIM>> &, + const std::vector<double> &, + const std::vector<double> &, + const std::vector<int> &, const size_t &, + double &, double &) = 0; virtual void AddRepAtomId(int _id) = 0; -}; \ No newline at end of file +}; diff --git a/src/boundaryconditions/externalForceApplicator.h b/src/boundaryconditions/externalForceApplicator.h index a7527ceaf..01624c3c3 100644 --- a/src/boundaryconditions/externalForceApplicator.h +++ b/src/boundaryconditions/externalForceApplicator.h @@ -13,13 +13,13 @@ public: double delta_; point<DIM> external_force_; - string name_string_; + std::string name_string_; double radius_; point<DIM> center_; - vector<point<DIM>> points_in_range_; - vector<point<DIM>> internal_force_points_in_range_; - vector<int> indices_points_in_range_; + std::vector<point<DIM>> points_in_range_; + std::vector<point<DIM>> internal_force_points_in_range_; + std::vector<int> indices_points_in_range_; public: virtual bool OutputFlag() const = 0; @@ -30,8 +30,9 @@ public: virtual void UpdatePosition() = 0; - virtual void ApplyForce(const vector<point<DIM>> &, const vector<double> &, - const size_t &, vector<point<DIM>> &) = 0; + virtual void ApplyForce(const std::vector<point<DIM>> &, + const std::vector<double> &, const size_t &, + std::vector<point<DIM>> &) = 0; virtual void RecordForce(const size_t &, const double &) = 0; -}; \ No newline at end of file +}; diff --git a/src/boundaryconditions/fixedboundary.h b/src/boundaryconditions/fixedboundary.h index 02ba9b7ee..865ee9362 100644 --- a/src/boundaryconditions/fixedboundary.h +++ b/src/boundaryconditions/fixedboundary.h @@ -25,10 +25,10 @@ public: this->bounds_[1] = _p2; this->bounds_[2] = _p3; } - void AssignZoneName(const string &_zone_name) { + void AssignZoneName(const std::string &_zone_name) { this->zone_name_ = _zone_name; } - void AssignNormal(const array<double, DIM> &_n) { this->normal_ = _n; } + void AssignNormal(const std::array<double, DIM> &_n) { this->normal_ = _n; } bool pointInBoundary(const point<DIM> &_p) { if (dot(_p, this->normal_) > abs(this->bound_)) { @@ -47,20 +47,21 @@ public: } void AddRepAtomId(int _id) { this->localrepatomids_.push_back(_id); } - void AddError(const vector<point<DIM>> &_atomLocations, - const vector<point<DIM>> &_atomForces, - const vector<double> &_atomWeights, - const vector<int> &_atomMultiplicities, const size_t &_n_ghosts, - double &_error, double &_error_bound) {} + void AddError(const std::vector<point<DIM>> &_atomLocations, + const std::vector<point<DIM>> &_atomForces, + const std::vector<double> &_atomWeights, + const std::vector<int> &_atomMultiplicities, + const size_t &_n_ghosts, double &_error, double &_error_bound) { + } - void AddThermalError(const vector<point<DIM>> &_atomLocations, - const vector<double> &_atomThermalForces, - const vector<double> &_atomWeights, - const vector<int> &_atomMultiplicities, + void AddThermalError(const std::vector<point<DIM>> &_atomLocations, + const std::vector<double> &_atomThermalForces, + const std::vector<double> &_atomWeights, + const std::vector<int> &_atomMultiplicities, const size_t &_n_ghosts, double &_error, double &_error_bound) {} - // void Update(vector<point<DIM>> &_atomVelocities) + // void Update(std::vector<point<DIM>> &_atomVelocities) // { // for(int id : this->localrepatomids_) // { @@ -68,8 +69,8 @@ public: // } // } - void Update(const vector<point<DIM>> &_atomLocations, - vector<point<DIM>> &_atomVelocities) { + void Update(const std::vector<point<DIM>> &_atomLocations, + std::vector<point<DIM>> &_atomVelocities) { for (size_t atomIndex = 0; atomIndex < _atomLocations.size(); atomIndex++) { if (pointInBoundary(_atomLocations[atomIndex])) { _atomVelocities[atomIndex].fill(0.0); @@ -77,12 +78,12 @@ public: } } - void UpdateForces(const vector<point<DIM>> &_atomLocations, - vector<point<DIM>> &_atomForces) { + void UpdateForces(const std::vector<point<DIM>> &_atomLocations, + std::vector<point<DIM>> &_atomForces) { for (size_t atomIndex = 0; atomIndex < _atomLocations.size(); atomIndex++) { if (pointInBoundary(_atomLocations[atomIndex])) { _atomForces[atomIndex].fill(0.0); } } } -}; \ No newline at end of file +}; diff --git a/src/boundaryconditions/freeboundary.h b/src/boundaryconditions/freeboundary.h index ba1880dee..c8eeab222 100644 --- a/src/boundaryconditions/freeboundary.h +++ b/src/boundaryconditions/freeboundary.h @@ -25,10 +25,10 @@ public: this->bounds_[1] = _p2; this->bounds_[2] = _p3; } - void AssignZoneName(const string &_zone_name) { + void AssignZoneName(const std::string &_zone_name) { this->zone_name_ = _zone_name; } - void AssignNormal(const array<double, DIM> &_n) { this->normal_ = _n; } + void AssignNormal(const std::array<double, DIM> &_n) { this->normal_ = _n; } void AddRepAtom(const point<DIM> &_atom_location, const int &_id, const int &_boundary_ctr, bool &_boundary_flag) { if (IfPointNearSegment<DIM>(_atom_location, this->bounds_, @@ -46,11 +46,11 @@ public: } return false; } - void AddError(const vector<point<DIM>> &_atomLocations, - const vector<point<DIM>> &_atomForces, - const vector<double> &_atomWeights, - const vector<int> &_atomMultiplicities, const size_t &_n_ghosts, - double &_error, double &_error_bound) { + void AddError(const std::vector<point<DIM>> &_atomLocations, + const std::vector<point<DIM>> &_atomForces, + const std::vector<double> &_atomWeights, + const std::vector<int> &_atomMultiplicities, + const size_t &_n_ghosts, double &_error, double &_error_bound) { for (size_t atomIndex = 0; atomIndex < _atomLocations.size() - _n_ghosts; atomIndex++) { if (pointInBoundary(_atomLocations[atomIndex])) { @@ -69,10 +69,10 @@ public: // } } - void AddThermalError(const vector<point<DIM>> &_atomLocations, - const vector<double> &_atomThermalForces, - const vector<double> &_atomWeights, - const vector<int> &_atomMultiplicities, + void AddThermalError(const std::vector<point<DIM>> &_atomLocations, + const std::vector<double> &_atomThermalForces, + const std::vector<double> &_atomWeights, + const std::vector<int> &_atomMultiplicities, const size_t &_n_ghosts, double &_error, double &_error_bound) { @@ -94,7 +94,7 @@ public: // double(_atomMultiplicities[id])); // } } - // void AddError(const vector<point<DIM>> &_atoms, + // void AddError(const std::vector<point<DIM>> &_atoms, // double &_error, double &_error_bound) // { // for(int id : this->localrepatomids_) @@ -108,11 +108,11 @@ public: // } // } - // void Update(vector<point<DIM>> &_atomVelocities){} + // void Update(std::vector<point<DIM>> &_atomVelocities){} - void Update(const vector<point<DIM>> &_atomLocations, - vector<point<DIM>> &_atomVelocities) {} + void Update(const std::vector<point<DIM>> &_atomLocations, + std::vector<point<DIM>> &_atomVelocities) {} - void UpdateForces(const vector<point<DIM>> &_atomLocations, - vector<point<DIM>> &_atomForces) {} + void UpdateForces(const std::vector<point<DIM>> &_atomLocations, + std::vector<point<DIM>> &_atomForces) {} }; diff --git a/src/boundaryconditions/nanoindenter_sphere.h b/src/boundaryconditions/nanoindenter_sphere.h index 753d9cfda..ce8a2b382 100644 --- a/src/boundaryconditions/nanoindenter_sphere.h +++ b/src/boundaryconditions/nanoindenter_sphere.h @@ -1,6 +1,7 @@ #pragma once #include "externalForceApplicator.h" +#include "mpiutilities.h" template <int DIM> class nanoindenter_sphere : public ExternalForceApplicator<DIM> { @@ -25,7 +26,7 @@ public: return (magnitude(_location - this->center_) < this->radius_); } void UpdatePosition(const double &_d) { - array<double, DIM> displacement; + std::array<double, DIM> displacement; displacement.fill(0.0); @@ -34,7 +35,7 @@ public: this->center_ += displacement; } void UpdatePosition() { - array<double, DIM> displacement; + std::array<double, DIM> displacement; displacement.fill(0.0); @@ -43,16 +44,17 @@ public: this->center_ += displacement; if (mpi_rank == 0) { - cout << "updated indenter center position " << this->center_ << endl; + std::cout << "updated indenter center position " << this->center_ + << std::endl; displacement = this->center_; displacement[2] -= this->radius_; - cout << "indenter lowest point at " << displacement << endl; + std::cout << "indenter lowest point at " << displacement << std::endl; } } - void ApplyForce(const vector<point<DIM>> &_locations, - const vector<double> &_weights, const size_t &_noofGhosts, - vector<point<DIM>> &_forces) { + void ApplyForce(const std::vector<point<DIM>> &_locations, + const std::vector<double> &_weights, + const size_t &_noofGhosts, std::vector<point<DIM>> &_forces) { point<DIM> r, f; double r_mag; @@ -97,35 +99,37 @@ public: mpi_utilities::ALLREDUCE_SUM<double, DIM>(this->external_force_, f); - string filename; + std::string filename; if (mpi_rank == 0) { - ofstream f_external; - filename = "./ExternalForce_sphere_" + to_string(2.0 * this->radius_) + - "_" + to_string(_n_repatoms) + "_" + to_string(_T) + ".dat"; + std::ofstream f_external; + filename = + "./ExternalForce_sphere_" + std::to_string(2.0 * this->radius_) + + "_" + std::to_string(_n_repatoms) + "_" + std::to_string(_T) + ".dat"; - f_external.open(filename, ios::app); - f_external << this->center_ << " " << f << endl; + f_external.open(filename, std::ios::app); + f_external << this->center_ << " " << f << std::endl; f_external.close(); - cout << this->center_ << endl; + std::cout << this->center_ << std::endl; } - ofstream f_points; - filename = "./External_spherePoints_" + to_string(2.0 * this->radius_) + - "_" + to_string(_n_repatoms) + "_" + to_string(_T) + "_" + - to_string(mpi_rank) + ".dat"; + std::ofstream f_points; + filename = "./External_spherePoints_" + + std::to_string(2.0 * this->radius_) + "_" + + std::to_string(_n_repatoms) + "_" + std::to_string(_T) + "_" + + std::to_string(mpi_rank) + ".dat"; if (this->points_in_range_.size() > 0) { - f_points.open(filename, ios::app); - f_points << "*****************************" << endl; - f_points << this->center_ << " " << f << endl; + f_points.open(filename, std::ios::app); + f_points << "*****************************" << std::endl; + f_points << this->center_ << " " << f << std::endl; for (int i = 0; i < this->points_in_range_.size(); i++) { f_points << i << " " << this->indices_points_in_range_[i] << " " << this->points_in_range_[i] << " " - << this->internal_force_points_in_range_[i] << endl; + << this->internal_force_points_in_range_[i] << std::endl; } f_points.close(); } } -}; \ No newline at end of file +}; diff --git a/src/boundaryconditions/nullapplicator.h b/src/boundaryconditions/nullapplicator.h index addf38eac..eae06fe11 100644 --- a/src/boundaryconditions/nullapplicator.h +++ b/src/boundaryconditions/nullapplicator.h @@ -21,9 +21,10 @@ public: void UpdatePosition(const double &_d) {} void UpdatePosition() {} - void ApplyForce(const vector<point<DIM>> &_locations, - const vector<double> &_weights, const size_t &_noofGhosts, - vector<point<DIM>> &_forces) {} + void ApplyForce(const std::vector<point<DIM>> &_locations, + const std::vector<double> &_weights, + const size_t &_noofGhosts, std::vector<point<DIM>> &_forces) { + } void RecordForce(const size_t &_n_repatoms, const double &_T) {} -}; \ No newline at end of file +}; diff --git a/src/boundaryconditions/slipboundary.h b/src/boundaryconditions/slipboundary.h index 70631be1a..9c56cb79c 100644 --- a/src/boundaryconditions/slipboundary.h +++ b/src/boundaryconditions/slipboundary.h @@ -26,10 +26,10 @@ public: this->bounds_[2] = _p3; } - void AssignZoneName(const string &_zone_name) { + void AssignZoneName(const std::string &_zone_name) { this->zone_name_ = _zone_name; } - void AssignNormal(const array<double, DIM> &_n) { this->normal_ = _n; } + void AssignNormal(const std::array<double, DIM> &_n) { this->normal_ = _n; } void AddRepAtom(const point<DIM> &_atom_location, const int &_id, const int &_boundary_ctr, bool &_boundary_flag) { if (IfPointNearSegment<DIM>(_atom_location, this->bounds_, @@ -47,7 +47,7 @@ public: return false; } - // void AddError(const vector<point<DIM>> &_atoms, + // void AddError(const std::vector<point<DIM>> &_atoms, // double &_error) // { // for(int id : this->localrepatomids_) @@ -55,18 +55,18 @@ public: // _error+= 0.0; // } // } - void AddError(const vector<point<DIM>> &_atomLocations, - const vector<point<DIM>> &_atomForces, - const vector<double> &_atomWeights, - const vector<int> &_atomMultiplicities, const size_t &, + void AddError(const std::vector<point<DIM>> &_atomLocations, + const std::vector<point<DIM>> &_atomForces, + const std::vector<double> &_atomWeights, + const std::vector<int> &_atomMultiplicities, const size_t &, double &_error, double &_error_bound) {} - void AddThermalError(const vector<point<DIM>> &_atomLocations, - const vector<double> &_atomThermalForces, - const vector<double> &_atomWeights, - const vector<int> &_atomMultiplicities, const size_t &, - double &_error, double &_error_bound) {} - // void Update(vector<point<DIM>> &_atomVelocities) + void AddThermalError(const std::vector<point<DIM>> &_atomLocations, + const std::vector<double> &_atomThermalForces, + const std::vector<double> &_atomWeights, + const std::vector<int> &_atomMultiplicities, + const size_t &, double &_error, double &_error_bound) {} + // void Update(std::vector<point<DIM>> &_atomVelocities) // { // for(int id : this->localrepatomids_) // { @@ -75,8 +75,8 @@ public: // } // } - void Update(const vector<point<DIM>> &_atomLocations, - vector<point<DIM>> &_atomVelocities) { + void Update(const std::vector<point<DIM>> &_atomLocations, + std::vector<point<DIM>> &_atomVelocities) { for (size_t atomIndex = 0; atomIndex < _atomLocations.size(); atomIndex++) { if (pointInBoundary(_atomLocations[atomIndex])) { _atomVelocities[atomIndex] -= @@ -87,8 +87,8 @@ public: // slip boundaries do not change anything in thermal velocities // we need isothermal tag for that - void UpdateForces(const vector<point<DIM>> &_atomLocations, - vector<point<DIM>> &_atomForces) { + void UpdateForces(const std::vector<point<DIM>> &_atomLocations, + std::vector<point<DIM>> &_atomForces) { for (size_t atomIndex = 0; atomIndex < _atomLocations.size(); atomIndex++) { if (pointInBoundary(_atomLocations[atomIndex])) { _atomForces[atomIndex] -= @@ -96,4 +96,4 @@ public: } } } -}; \ No newline at end of file +}; diff --git a/src/boundaryconditions/straight_press.h b/src/boundaryconditions/straight_press.h index 2f3328ccd..d80e082f3 100644 --- a/src/boundaryconditions/straight_press.h +++ b/src/boundaryconditions/straight_press.h @@ -14,7 +14,7 @@ public: point<DIM> center_; point<DIM> external_force_; - string name_string_; + std::string name_string_; straight_press(double _r, double _f, double _d, point<DIM> _c) { this->radius_ = _r; @@ -30,7 +30,7 @@ public: bool OutputFlag() const { return false; } void UpdatePosition(const double &_d) { - array<double, DIM> displacement; + std::array<double, DIM> displacement; displacement.fill(0.0); @@ -39,7 +39,7 @@ public: this->center_ += displacement; } void UpdatePosition() { - array<double, DIM> displacement; + std::array<double, DIM> displacement; displacement.fill(0.0); @@ -79,4 +79,4 @@ public: f / double(_container.node_multiplicities_[repatom_idx]); } } -}; \ No newline at end of file +}; diff --git a/src/common/Euclidean.h b/src/common/Euclidean.h index 7ace7ca1e..c8958e3d9 100644 --- a/src/common/Euclidean.h +++ b/src/common/Euclidean.h @@ -23,9 +23,6 @@ #include "utilities.h" #include "variables.h" -using namespace std; -using namespace geometry; - // template<int _K> // class plane // { @@ -54,11 +51,11 @@ using namespace geometry; template <int _K, class Point> class StraightBoundary { public: - vector<Point> DefiningPoints; + std::vector<Point> DefiningPoints; StraightBoundary() { this->DefiningPoints.resize(_K); }; - StraightBoundary(const vector<Point> &_points) { + StraightBoundary(const std::vector<Point> &_points) { copy(_points.begin(), _points.end(), back_inserter(this->DefiningPoints)); } @@ -81,7 +78,8 @@ void ConvertLibPoint2MyPoint(CgalPoint _cp, MyPoint &_mp) { } template <class CgalPoint, class MyPoint, int _K> -void ConvertLibPoints2MyPoints(vector<CgalPoint> _cps, vector<MyPoint> &_mps) { +void ConvertLibPoints2MyPoints(std::vector<CgalPoint> _cps, + std::vector<MyPoint> &_mps) { _mps.resize(_cps.size()); int mp_ctr = 0; @@ -105,10 +103,11 @@ void ConvertMyPoint2LibPoint<CGAL_POINT_3, 3>(CGAL_POINT_3 &_cp, point<3> _mp) { } template <class PointClass> -array<unsigned int, 2> FindLongestEdgeOfSimplex(array<PointClass, 3> &simplex, - double &maxLength) { +std::array<unsigned int, 2> +FindLongestEdgeOfSimplex(std::array<PointClass, 3> &simplex, + double &maxLength) { - array<unsigned int, 2> longestEdge = {{unsigned(0), unsigned(1)}}; + std::array<unsigned int, 2> longestEdge = {{unsigned(0), unsigned(1)}}; maxLength = simplex[0].distance(simplex[1]); double testLength = simplex[2].distance(simplex[0]); @@ -128,9 +127,10 @@ array<unsigned int, 2> FindLongestEdgeOfSimplex(array<PointClass, 3> &simplex, } template <class PointClass> -array<unsigned int, 2> FindLongestEdgeOfSimplex(array<PointClass, 4> &simplex, - double &maxLength) { - array<unsigned int, 2> longestEdge = {{unsigned(0), unsigned(1)}}; +std::array<unsigned int, 2> +FindLongestEdgeOfSimplex(std::array<PointClass, 4> &simplex, + double &maxLength) { + std::array<unsigned int, 2> longestEdge = {{unsigned(0), unsigned(1)}}; maxLength = simplex[1].distance(simplex[0]); double testLength = simplex[2].distance(simplex[0]); @@ -173,7 +173,7 @@ array<unsigned int, 2> FindLongestEdgeOfSimplex(array<PointClass, 4> &simplex, } template <class PointClass> -int FindLongestEdgeOfSimplex(const array<PointClass, 3> &_simplex) { +int FindLongestEdgeOfSimplex(const std::array<PointClass, 3> &_simplex) { int longestEdge = 2; double maxLength = _simplex[0].distance(_simplex[1]); @@ -192,7 +192,7 @@ int FindLongestEdgeOfSimplex(const array<PointClass, 3> &_simplex) { } template <class PointClass> -int FindLongestEdgeOfSimplex(const vector<PointClass> &_simplex) { +int FindLongestEdgeOfSimplex(const std::vector<PointClass> &_simplex) { int longestEdge = 2; double maxLength = _simplex[0].distance(_simplex[1]); @@ -211,10 +211,11 @@ int FindLongestEdgeOfSimplex(const vector<PointClass> &_simplex) { } template <class PointClass> -array<unsigned int, 2> FindShortestEdgeOfSimplex(array<PointClass, 3> &simplex, - double &minLength) { +std::array<unsigned int, 2> +FindShortestEdgeOfSimplex(std::array<PointClass, 3> &simplex, + double &minLength) { - array<unsigned int, 2> shortestEdge = {{unsigned(0), unsigned(1)}}; + std::array<unsigned int, 2> shortestEdge = {{unsigned(0), unsigned(1)}}; minLength = simplex[0].distance(simplex[1]); double testLength = simplex[2].distance(simplex[0]); @@ -233,9 +234,10 @@ array<unsigned int, 2> FindShortestEdgeOfSimplex(array<PointClass, 3> &simplex, return shortestEdge; } template <class PointClass> -array<unsigned int, 3> FindShortestEdgeOfSimplex(array<PointClass, 4> &simplex, - double &minLength) { - array<unsigned int, 3> shortestEdge = {{unsigned(0), unsigned(1)}}; +std::array<unsigned int, 3> +FindShortestEdgeOfSimplex(std::array<PointClass, 4> &simplex, + double &minLength) { + std::array<unsigned int, 3> shortestEdge = {{unsigned(0), unsigned(1)}}; minLength = simplex[1].distance(simplex[0]); double testLength = simplex[2].distance(simplex[0]); @@ -278,12 +280,12 @@ array<unsigned int, 3> FindShortestEdgeOfSimplex(array<PointClass, 4> &simplex, } template <int _K> -point<_K> computeInwardNormalToSide(const array<point<_K>, _K + 1> &, - const vector<int> &, point<_K>); +point<_K> computeInwardNormalToSide(const std::array<point<_K>, _K + 1> &, + const std::vector<int> &, point<_K>); template <> -point<2> computeInwardNormalToSide<2>(const array<point<2>, 3> &_simplex, - const vector<int> &_vertidx, +point<2> computeInwardNormalToSide<2>(const std::array<point<2>, 3> &_simplex, + const std::vector<int> &_vertidx, point<2> _barycenter) { point<2> tangent = _simplex[_vertidx[1]] - _simplex[_vertidx[0]]; point<2> normal; @@ -291,7 +293,7 @@ point<2> computeInwardNormalToSide<2>(const array<point<2>, 3> &_simplex, normal[0] = tangent[1]; normal[1] = -tangent[0]; - normalize<double, 2>(&normal); + std::normalize<double, 2>(&normal); point<2> to_barycenter = _barycenter - _simplex[_vertidx[0]]; @@ -305,8 +307,8 @@ point<2> computeInwardNormalToSide<2>(const array<point<2>, 3> &_simplex, } template <> -point<3> computeInwardNormalToSide<3>(const array<point<3>, 4> &_simplex, - const vector<int> &_vertidx, +point<3> computeInwardNormalToSide<3>(const std::array<point<3>, 4> &_simplex, + const std::vector<int> &_vertidx, point<3> _barycenter) { point<3> tangent1 = _simplex[_vertidx[1]] - _simplex[_vertidx[0]]; @@ -314,7 +316,7 @@ point<3> computeInwardNormalToSide<3>(const array<point<3>, 4> &_simplex, point<3> normal = cross(tangent1, tangent2); - normalize<double, 3>(&normal); + std::normalize<double, 3>(&normal); point<3> to_barycenter = _barycenter - _simplex[_vertidx[0]]; @@ -342,8 +344,8 @@ template <int _K> bool insideSimplex(const point<_K> &, const std::array<point<_K>, _K + 1> &); // template<int _K> -// void FlipEdgesSimplices2_2(vector<point<_K>> &_vertices_1, -// vector<point<_K>> &_vertices_2, vector<int> edges) +// void FlipEdgesSimplices2_2(std::vector<point<_K>> &_vertices_1, +// std::vector<point<_K>> &_vertices_2, std::vector<int> edges) template <> point<2> projection<2, 2>(const point<2> &_pt, const std::array<point<2>, 2> &_line) { @@ -355,11 +357,12 @@ point<2> projection<2, 2>(const point<2> &_pt, point<2> _v = _pt - _line[0]; - double cos_theta = dot(line_v, _v) / (magnitude(line_v) * magnitude(_v)); + double cos_theta = + dot(line_v, _v) / (std::magnitude(line_v) * std::magnitude(_v)); - double t = cos_theta * magnitude(_v); + double t = cos_theta * std::magnitude(_v); - normalize<double, 2>(&line_v); + std::normalize<double, 2>(&line_v); inter_pt = line_v * t + _line[0]; @@ -376,11 +379,12 @@ point<3> projection<3, 2>(const point<3> &_pt, point<3> _v = _pt - _line[0]; - double cos_theta = dot(line_v, _v) / (magnitude(line_v) * magnitude(_v)); + double cos_theta = + dot(line_v, _v) / (std::magnitude(line_v) * std::magnitude(_v)); - double t = cos_theta * magnitude(_v); + double t = cos_theta * std::magnitude(_v); - normalize<double, 3>(&line_v); + std::normalize<double, 3>(&line_v); inter_pt = line_v * t + _line[0]; @@ -398,7 +402,7 @@ point<3> projection<3, 3>(const point<3> &_pt, point<3> line_v = _pt - _plane[0]; point<3> normal = cross(t1, t2); - normalize<double, 3>(&normal); + std::normalize<double, 3>(&normal); double t = dot(line_v, normal); @@ -414,7 +418,7 @@ bool IfPointNearSegment(const point<_K> &_pt, point<_K> v1 = _segment[0] - _pt; point<_K> v2 = _segment[1] - _pt; - if (magnitude(v1) < _tolerance or magnitude(v2) < _tolerance) { + if (std::magnitude(v1) < _tolerance or std::magnitude(v2) < _tolerance) { // on_seg = false; on_seg = true; } else { @@ -426,7 +430,7 @@ bool IfPointNearSegment(const point<_K> &_pt, // asin(_tolerance/v2.magnitude())); angle_tolerance = _tolerance; } - double cosTheta = dot(v1, v2) / (magnitude(v1) * magnitude(v2)); + double cosTheta = dot(v1, v2) / (std::magnitude(v1) * std::magnitude(v2)); if (std::abs(cosTheta + 1.0) < angle_tolerance) { on_seg = true; @@ -442,7 +446,7 @@ bool IfPointNearSegment(const point<_K> &_pt, const point<_K> &_segment_1, point<_K> v1 = _segment_1 - _pt; point<_K> v2 = _segment_2 - _pt; - if (magnitude(v1) < _tolerance or magnitude(v2) < _tolerance) { + if (std::magnitude(v1) < _tolerance or std::magnitude(v2) < _tolerance) { // on_seg = false; on_seg = true; } else { @@ -454,7 +458,7 @@ bool IfPointNearSegment(const point<_K> &_pt, const point<_K> &_segment_1, // asin(_tolerance/v2.magnitude())); angle_tolerance = _tolerance; } - double cosTheta = dot(v1, v2) / (magnitude(v1) * magnitude(v2)); + double cosTheta = dot(v1, v2) / (std::magnitude(v1) * std::magnitude(v2)); if (std::abs(cosTheta + 1.0) < angle_tolerance) { on_seg = true; @@ -464,18 +468,20 @@ bool IfPointNearSegment(const point<_K> &_pt, const point<_K> &_segment_1, } template <int _K> -bool IfPointNearSegment(const point<_K> &, const vector<point<_K>> &, +bool IfPointNearSegment(const point<_K> &, const std::vector<point<_K>> &, const double &); template <> -bool IfPointNearSegment<2>(const point<2> &_pt, const vector<point<2>> &_bounds, +bool IfPointNearSegment<2>(const point<2> &_pt, + const std::vector<point<2>> &_bounds, const double &_tolerance) { return IfPointNearSegment<2>(_pt, _bounds[0], _bounds[1], _tolerance); } template <> -bool IfPointNearSegment<3>(const point<3> &_pt, const vector<point<3>> &_bounds, +bool IfPointNearSegment<3>(const point<3> &_pt, + const std::vector<point<3>> &_bounds, const double &_tolerance) { - array<point<3>, 3> _bounds_array; + std::array<point<3>, 3> _bounds_array; _bounds_array[0] = _bounds[0]; _bounds_array[1] = _bounds[1]; _bounds_array[2] = _bounds[2]; @@ -514,7 +520,7 @@ double simplexSignedDistance<2>(const point<2> &_pt, double projection = dot(point_to_side, normal_to_side) / - (magnitude(point_to_side) * magnitude(normal_to_side)); + (std::magnitude(point_to_side) * std::magnitude(normal_to_side)); inside.emplace_back(projection / std::abs(projection)); @@ -568,7 +574,7 @@ double simplexSignedDistance<3>(const point<3> &_pt, double projection = dot(vector_to_side, normal_to_side) / - (magnitude(vector_to_side) * magnitude(normal_to_side)); + (std::magnitude(vector_to_side) * std::magnitude(normal_to_side)); inside.emplace_back(projection / std::abs(projection)); @@ -629,7 +635,7 @@ double simplexSignedDistance<3>(const point<3> &_pt, double projection_to_side = dot(normal_to_side, vector_to_side) / - (magnitude(normal_to_side) * magnitude(vector_to_side)); + (std::magnitude(normal_to_side) * std::magnitude(vector_to_side)); inside.emplace_back(projection_to_side / std::abs(projection_to_side)); @@ -713,12 +719,12 @@ double simplexSignedDistance<3>(const point<3> &_pt, } template <int DIM> -void getSolidAnglesOfSimplex(const array<point<DIM>, DIM + 1> &, - vector<double> &); +void getSolidAnglesOfSimplex(const std::array<point<DIM>, DIM + 1> &, + std::vector<double> &); template <> -void getSolidAnglesOfSimplex<2>(const array<point<2>, 3> &_simplex, - vector<double> &_angles) { +void getSolidAnglesOfSimplex<2>(const std::array<point<2>, 3> &_simplex, + std::vector<double> &_angles) { _angles.resize(3); point<2> side_vector_1; @@ -728,18 +734,18 @@ void getSolidAnglesOfSimplex<2>(const array<point<2>, 3> &_simplex, side_vector_1 = _simplex[(i_n + 1) % 3] - _simplex[i_n]; side_vector_2 = _simplex[(i_n + 2) % 3] - _simplex[i_n]; - normalize<double, 2>(&side_vector_1); - normalize<double, 2>(&side_vector_2); + std::normalize<double, 2>(&side_vector_1); + std::normalize<double, 2>(&side_vector_2); - _angles[i_n] = - abs(acos(dot(side_vector_1, side_vector_2) / - (magnitude(side_vector_1) * magnitude(side_vector_2)))); + _angles[i_n] = abs( + acos(dot(side_vector_1, side_vector_2) / + (std::magnitude(side_vector_1) * std::magnitude(side_vector_2)))); } } template <> -void getSolidAnglesOfSimplex<3>(const array<point<3>, 4> &_simplex, - vector<double> &_angles) { +void getSolidAnglesOfSimplex<3>(const std::array<point<3>, 4> &_simplex, + std::vector<double> &_angles) { _angles.resize(4); point<3> side_vector_1; @@ -755,11 +761,12 @@ void getSolidAnglesOfSimplex<3>(const array<point<3>, 4> &_simplex, tripleProduct = dot(cross(side_vector_2, side_vector_3), side_vector_1); - div = magnitude(side_vector_1) * magnitude(side_vector_2) * - magnitude(side_vector_3) + - dot(side_vector_1, side_vector_2) * magnitude(side_vector_3); - dot(side_vector_3, side_vector_2) * magnitude(side_vector_1); - dot(side_vector_1, side_vector_3) * magnitude(side_vector_2); + div = + std::magnitude(side_vector_1) * std::magnitude(side_vector_2) * + std::magnitude(side_vector_3) + + std::dot(side_vector_1, side_vector_2) * std::magnitude(side_vector_3); + std::dot(side_vector_3, side_vector_2) * std::magnitude(side_vector_1); + std::dot(side_vector_1, side_vector_3) * std::magnitude(side_vector_2); double arctan = atan2(tripleProduct, div); _angles[i_n] = 2 * ((arctan < 0) ? (arctan + PI) : arctan); @@ -767,12 +774,12 @@ void getSolidAnglesOfSimplex<3>(const array<point<3>, 4> &_simplex, } template <typename point_d, int _K> -void LinearInterpolatorSimplex(const array<point_d, _K + 1> &, const point_d &, - vector<double> &); +void LinearInterpolatorSimplex(const std::array<point_d, _K + 1> &, + const point_d &, std::vector<double> &); -template <int _K> void CheckShapeFunctionBounds(vector<double> &); +template <int _K> void CheckShapeFunctionBounds(std::vector<double> &); -template <> void CheckShapeFunctionBounds<2>(vector<double> &_N_i) { +template <> void CheckShapeFunctionBounds<2>(std::vector<double> &_N_i) { if ((_N_i[0] + GeometryTolerance < 0.0) || (_N_i[1] + GeometryTolerance < 0.0) || (_N_i[2] + GeometryTolerance < 0.0)) { @@ -790,7 +797,7 @@ template <> void CheckShapeFunctionBounds<2>(vector<double> &_N_i) { } } -template <> void CheckShapeFunctionBounds<3>(vector<double> &_N_i) { +template <> void CheckShapeFunctionBounds<3>(std::vector<double> &_N_i) { if ((_N_i[0] + GeometryTolerance < 0.0) || (_N_i[1] + GeometryTolerance < 0.0) || (_N_i[2] + GeometryTolerance < 0.0) || @@ -814,8 +821,8 @@ template <> void CheckShapeFunctionBounds<3>(vector<double> &_N_i) { template <> void LinearInterpolatorSimplex<point<2>, 2>( - const array<point<2>, 2 + 1> &_triangle, const point<2> &_p, - vector<double> &_N_i) { + const std::array<point<2>, 2 + 1> &_triangle, const point<2> &_p, + std::vector<double> &_N_i) { int vertex = -1; for (int d = 0; d < 3; d++) { if (_p == _triangle[d]) { @@ -829,7 +836,7 @@ void LinearInterpolatorSimplex<point<2>, 2>( _N_i[(vertex + 1) % 3] = 0.0; _N_i[(vertex + 2) % 3] = 0.0; } else { - array<point<2>, 2 + 1> subvertices; + std::array<point<2>, 2 + 1> subvertices; double volume = simplexVolume<2>(_triangle); subvertices[0] = _p; @@ -858,8 +865,8 @@ void LinearInterpolatorSimplex<point<2>, 2>( template <> void LinearInterpolatorSimplex<point<3>, 3>( - const array<point<3>, 3 + 1> &_tetrahedron, const point<3> &_p, - vector<double> &_N_i) { + const std::array<point<3>, 3 + 1> &_tetrahedron, const point<3> &_p, + std::vector<double> &_N_i) { if (_N_i.size() == 0) _N_i.resize(4); @@ -880,7 +887,7 @@ void LinearInterpolatorSimplex<point<3>, 3>( } else { double volume = simplexVolume<3>(_tetrahedron); - array<point<3>, 3 + 1> subvertices; + std::array<point<3>, 3 + 1> subvertices; subvertices[0] = _p; subvertices[1] = _tetrahedron[1]; @@ -926,7 +933,7 @@ bool CheckPointOnBox<point<2>, 2>(const point<2> &_p, const Box<point<2>, 2> &_box) { bool present = false; - vector<array<point<2>, 2>> boundaries(4); + std::vector<std::array<point<2>, 2>> boundaries(4); boundaries[0][0] = _box.lower_; boundaries[0][1] = {_box.lower_[0], _box.upper_[1]}; @@ -972,7 +979,7 @@ bool CheckPointOnBox<point<3>, 3>(const point<3> &_p, // for box in 3D, we have to check on both // faces and edges. Faces - vector<array<point<3>, 3>> boundaries(6); + std::vector<std::array<point<3>, 3>> boundaries(6); // zmin 1-2-3 boundaries[0][0] = _box.lower_; boundaries[0][1] = {_box.upper_[0], _box.lower_[1], _box.lower_[2]}; @@ -1054,7 +1061,7 @@ bool CheckSimplexInBall(const std::array<point_d, _K + 1> &, // if(!intersection) // { -// vector<point<2>> box_points(4); +// std::vector<point<2>> box_points(4); // box_points[0] = _box.lower_; // box_points[1] = point<2>(_box.lower_[0], _box.upper_[1]); @@ -1119,7 +1126,7 @@ bool CheckIfPointCloseToStraightBoundary<CGAL_POINT_2, 2>( // _mpB1); ConvertLibPoint2MyPoint<2, CGAL_POINT, point<2>>( // _d.DefiningPoints[1], _mpB2); - array<point<2>, 2> segment; + std::array<point<2>, 2> segment; segment[0] = _d.DefiningPoints[0]; segment[1] = _d.DefiningPoints[1]; @@ -1141,7 +1148,7 @@ bool CheckIfPointCloseToStraightBoundary<point<2>, 2>( // _mpB1); ConvertLibPoint2MyPoint<2, CGAL_POINT, point<2>>( // _d.DefiningPoints[1], _mpB2); - array<point<2>, 2> segment; + std::array<point<2>, 2> segment; segment[0] = _d.DefiningPoints[0]; segment[1] = _d.DefiningPoints[1]; @@ -1153,13 +1160,13 @@ bool CheckIfPointCloseToStraightBoundary<point<2>, 2>( } // template<int _K, class Point> -// double ComputeSimplexQuality(const vector<Point> &); +// double ComputeSimplexQuality(const std::vector<Point> &); // template<int _K, class Point> -// double ComputeSimplexQuality(const vector<Point> &); +// double ComputeSimplexQuality(const std::vector<Point> &); // template<> -// double ComputeSimplexQuality<2, point<2>>(const vector<point<2>> &_points) +// double ComputeSimplexQuality<2, point<2>>(const std::vector<point<2>> &_points) // { // Eigen::Matrix<double, 2, 2> A; // Eigen::Matrix<double, 2, 2> W; @@ -1186,20 +1193,18 @@ bool CheckIfPointCloseToStraightBoundary<point<2>, 2>( // } template <int _K> -void ComputeSimplexPartitionVolumes(const array<point<_K>, _K + 1> &, +void ComputeSimplexPartitionVolumes(const std::array<point<_K>, _K + 1> &, const double &, - const array<double, _K + 1> &, + const std::array<double, _K + 1> &, const double &, const double &, - array<double, _K + 1> &, double &); + std::array<double, _K + 1> &, double &); template <> -void ComputeSimplexPartitionVolumes<2>(const array<point<2>, 2 + 1> &_simplex, - const double &_volume, - const array<double, 2 + 1> &_angles, - const double &_node_radius, - const double &_side_radius, - array<double, 2 + 1> &_node_volumes, - double &_barycenter_volume) { +void ComputeSimplexPartitionVolumes<2>( + const std::array<point<2>, 2 + 1> &_simplex, const double &_volume, + const std::array<double, 2 + 1> &_angles, const double &_node_radius, + const double &_side_radius, std::array<double, 2 + 1> &_node_volumes, + double &_barycenter_volume) { double node_radius_min; double total_node_volumes = 0.0; @@ -1207,20 +1212,21 @@ void ComputeSimplexPartitionVolumes<2>(const array<point<2>, 2 + 1> &_simplex, node_radius_min = _node_radius; point<2> node = _simplex[nodenumber]; - array<point<2>, 2> otherside; + std::array<point<2>, 2> otherside; // get minimum w.r.t. edge centers for (int othernodenumber = 1; othernodenumber < 2 + 1; othernodenumber++) { point<2> othernode = _simplex[(nodenumber + othernodenumber) % (2 + 1)]; otherside[othernodenumber - 1] = othernode; - node_radius_min = min(node_radius_min, 0.5 * distance(node, othernode)); + node_radius_min = + std::min(node_radius_min, 0.5 * distance(node, othernode)); } // compare with the normal distance // to other side double normal_distance = distance(node, projection<2, 2>(node, otherside)); - node_radius_min = min(node_radius_min, normal_distance); + node_radius_min = std::min(node_radius_min, normal_distance); _node_volumes[nodenumber] = 0.5 * _angles[nodenumber] * (node_radius_min * node_radius_min); @@ -1231,13 +1237,11 @@ void ComputeSimplexPartitionVolumes<2>(const array<point<2>, 2 + 1> &_simplex, _barycenter_volume = _volume - total_node_volumes; } template <> -void ComputeSimplexPartitionVolumes<3>(const array<point<3>, 3 + 1> &_simplex, - const double &_volume, - const array<double, 3 + 1> &_angles, - const double &_node_radius, - const double &_side_radius, - array<double, 3 + 1> &_node_volumes, - double &_barycenter_volume) { +void ComputeSimplexPartitionVolumes<3>( + const std::array<point<3>, 3 + 1> &_simplex, const double &_volume, + const std::array<double, 3 + 1> &_angles, const double &_node_radius, + const double &_side_radius, std::array<double, 3 + 1> &_node_volumes, + double &_barycenter_volume) { double node_radius_min; double total_node_volumes = 0.0; @@ -1248,8 +1252,8 @@ void ComputeSimplexPartitionVolumes<3>(const array<point<3>, 3 + 1> &_simplex, node_radius_min = _node_radius; point<3> node = _simplex[nodenumber]; - array<point<3>, 3> otherside; - // vector<double> planar_angle_cos(3); + std::array<point<3>, 3> otherside; + // std::vector<double> planar_angle_cos(3); // double A, B, C; // // get minimum w.r.t. edge centers @@ -1258,7 +1262,8 @@ void ComputeSimplexPartitionVolumes<3>(const array<point<3>, 3 + 1> &_simplex, otherside[othernodenumber - 1] = othernode; - node_radius_min = min(node_radius_min, 0.5 * distance(node, othernode)); + node_radius_min = + std::min(node_radius_min, 0.5 * distance(node, othernode)); } // for(int edge=0; edge<3; edge++) @@ -1291,7 +1296,7 @@ void ComputeSimplexPartitionVolumes<3>(const array<point<3>, 3 + 1> &_simplex, // sqrt(1.0 - pow(planar_angle_cos[1],2.0))* // sqrt(1.0 - pow(planar_angle_cos[0],2.0))); - node_radius_min = min(node_radius_min, normal_distance); + node_radius_min = std::min(node_radius_min, normal_distance); // _node_volumes[nodenumber] = // (A + B + C - PI)*pow(node_radius_min, 3.0)/3.0; @@ -1301,8 +1306,9 @@ void ComputeSimplexPartitionVolumes<3>(const array<point<3>, 3 + 1> &_simplex, total_node_volumes += _node_volumes[nodenumber]; if (std::isnan(_node_volumes[nodenumber])) { - cout << mpi_rank << " , " << _node_radius << " , " << _angles[nodenumber] - << " , " << node_radius_min << " , " << _volume << endl; + std::cout << mpi_rank << " , " << _node_radius << " , " + << _angles[nodenumber] << " , " << node_radius_min << " , " + << _volume << std::endl; } assert(!std::isnan(_node_volumes[nodenumber])); assert(!std::isinf(_node_volumes[nodenumber])); @@ -1320,7 +1326,8 @@ void ComputeSimplexPartitionVolumes<3>(const array<point<3>, 3 + 1> &_simplex, template <int _K> void ComputeEdgesProjectionOnLattice( - const vector<point<_K>> &_edges, const vector<vector<double>> &_vectors, + const std::vector<point<_K>> &_edges, + const std::vector<std::vector<double>> &_vectors, Eigen::Matrix<int, _K, _K> &_lattice_numbers) { Eigen::Matrix<double, _K, _K> edges; Eigen::Matrix<double, _K, _K> vectors; @@ -1345,8 +1352,8 @@ void ComputeEdgesProjectionOnLattice( template <int _K> void ComputeElementVolumeToAtomisticElementVolume( - const vector<point<_K>> &_edges, const vector<vector<double>> &_vectors, - int &_n_space_det) { + const std::vector<point<_K>> &_edges, + const std::vector<std::vector<double>> &_vectors, int &_n_space_det) { Eigen::Matrix<double, _K, _K> edges; Eigen::Matrix<double, _K, _K> vectors; diff --git a/src/common/interpolators.h b/src/common/interpolators.h index 2e712ca68..8b85770d4 100644 --- a/src/common/interpolators.h +++ b/src/common/interpolators.h @@ -29,9 +29,9 @@ public: gsl_spline_free(spline_); } - void initialize(const vector<pair<double, double>> &data) { - vector<double> domain; - vector<double> range; + void initialize(const std::vector<std::pair<double, double>> &data) { + std::vector<double> domain; + std::vector<double> range; for (const auto &d : data) { domain.push_back(d.first); @@ -59,4 +59,4 @@ public: double getDomainMax() const { return domainMax_; } double getLastRangeValue() const { return lastRangeValue_; } -}; \ No newline at end of file +}; diff --git a/src/common/mpiutilities.h b/src/common/mpiutilities.h index 0c0f96587..c95bfa3d6 100644 --- a/src/common/mpiutilities.h +++ b/src/common/mpiutilities.h @@ -4,7 +4,6 @@ #include <StandardHeaders.h> #include <mpi_var.h> -using namespace std; namespace mpi_utilities { template <typename T> MPI_Datatype Type(); @@ -18,7 +17,7 @@ MPI_Datatype MPI_Key(); void ExitOnError(const int error) { // if (error) std::exit(error); if (error) { - cout << "exiting due to error here " << endl; + std::cout << "exiting due to error here " << std::endl; exit(error); } } @@ -42,12 +41,13 @@ template <typename T> void ALLREDUCE_SUM(const T &_lT, T &_gT) { } template <typename T> -void ALLREDUCE_SUM(const vector<T> &_lT, vector<T> &_gT, const int &_N) { +void ALLREDUCE_SUM(const std::vector<T> &_lT, std::vector<T> &_gT, + const int &_N) { ExitOnError(MPI_Allreduce(&(_lT[0]), &(_gT[0]), _N, Type<T>(), MPI_SUM, MPI_COMM_WORLD)); } template <typename T, int DIM> -void ALLREDUCE_SUM(const array<T, DIM> &_lp, array<T, DIM> &_gp) { +void ALLREDUCE_SUM(const std::array<T, DIM> &_lp, std::array<T, DIM> &_gp) { ExitOnError(MPI_Allreduce(&(_lp[0]), &(_gp[0]), DIM, Type<T>(), MPI_SUM, MPI_COMM_WORLD)); } @@ -57,47 +57,49 @@ template <typename T> void ALLREDUCE_MAX(const T &_lT, T &_gT) { } template <typename T> -void ALLREDUCE_MAX(const vector<T> &_lT, vector<T> &_gT, const int &_N) { +void ALLREDUCE_MAX(const std::vector<T> &_lT, std::vector<T> &_gT, + const int &_N) { ExitOnError(MPI_Allreduce(&(_lT[0]), &(_gT[0]), _N, Type<T>(), MPI_MAX, MPI_COMM_WORLD)); } template <typename T, int DIM> -void ALLREDUCE_MAX(const array<T, DIM> &_lp, array<T, DIM> &_gp) { +void ALLREDUCE_MAX(const std::array<T, DIM> &_lp, std::array<T, DIM> &_gp) { ExitOnError(MPI_Allreduce(&(_lp[0]), &(_gp[0]), DIM, Type<T>(), MPI_MAX, MPI_COMM_WORLD)); } template <typename T, int DIM> -void ALLREDUCE_MIN(const array<T, DIM> &_lp, array<T, DIM> &_gp) { +void ALLREDUCE_MIN(const std::array<T, DIM> &_lp, std::array<T, DIM> &_gp) { ExitOnError(MPI_Allreduce(&(_lp[0]), &(_gp[0]), DIM, Type<T>(), MPI_MIN, MPI_COMM_WORLD)); } template <typename T> -void ALLGATHER(const T &_lT, vector<T> &_gT, const int &_dim = 1) { +void ALLGATHER(const T &_lT, std::vector<T> &_gT, const int &_dim = 1) { int _lTd = _lT * _dim; ExitOnError(MPI_Allgather(&_lTd, 1, Type<T>(), &(_gT[0]), 1, Type<T>(), MPI_COMM_WORLD)); } -template <typename T> void ALLGATHER1D(const T &_lT, vector<T> &_gT) { +template <typename T> void ALLGATHER1D(const T &_lT, std::vector<T> &_gT) { ExitOnError(MPI_Allgather(&_lT, 1, Type<T>(), &(_gT[0]), 1, Type<T>(), MPI_COMM_WORLD)); } template <typename T> -void ALLGATHERV(const vector<T> &_lT, vector<T> &_gT, const vector<int> &_N, - const vector<int> &_D) { +void ALLGATHERV(const std::vector<T> &_lT, std::vector<T> &_gT, + const std::vector<int> &_N, const std::vector<int> &_D) { ExitOnError(MPI_Allgatherv(&_lT[0], _N[mpi_rank], Type<T>(), &_gT[0], &_N[0], &_D[0], Type<T>(), MPI_COMM_WORLD)); } template <typename T, int N> -void ALLGATHERV_CUSTOM(const vector<T> &_lT, vector<T> &_gT, - const vector<int> &_N, const vector<int> &_D) { +void ALLGATHERV_CUSTOM(const std::vector<T> &_lT, std::vector<T> &_gT, + const std::vector<int> &_N, const std::vector<int> &_D) { MPI_Datatype mpi_type = ContiguousType< - typename remove_reference<decltype(std::declval<T>()[0])>::type, N>(); + typename std::remove_reference<decltype(std::declval<T>()[0])>::type, + N>(); ExitOnError(MPI_Allgatherv(&_lT[0], _N[mpi_rank], mpi_type, &_gT[0], &_N[0], &_D[0], mpi_type, MPI_COMM_WORLD)); @@ -106,27 +108,29 @@ void ALLGATHERV_CUSTOM(const vector<T> &_lT, vector<T> &_gT, } template <typename T> -void SCATTER(const vector<T> &_v, T &_l, const int &_root) { +void SCATTER(const std::vector<T> &_v, T &_l, const int &_root) { ExitOnError(MPI_Scatter(&_v[0], 1, Type<T>(), &_l, 1, Type<T>(), _root, MPI_COMM_WORLD)); } template <typename T> -void SCATTERV(const vector<T> &_v, vector<T> &_lv, const vector<int> &_counts, - const vector<int> &_disps, const int &_recvCount, - const int &_root) { +void SCATTERV(const std::vector<T> &_v, std::vector<T> &_lv, + const std::vector<int> &_counts, const std::vector<int> &_disps, + const int &_recvCount, const int &_root) { ExitOnError(MPI_Scatterv(&_v[0], &_counts[0], &_disps[0], Type<T>(), &_lv[0], _recvCount, Type<T>(), _root, MPI_COMM_WORLD)); } template <typename T, int N> -void SCATTERV_CUSTOM(const vector<T> &_v, vector<T> &_lv, - const vector<int> &_counts, const vector<int> &_disps, - const int &_recvCount, const int &_root) { +void SCATTERV_CUSTOM(const std::vector<T> &_v, std::vector<T> &_lv, + const std::vector<int> &_counts, + const std::vector<int> &_disps, const int &_recvCount, + const int &_root) { MPI_Datatype mpi_type = ContiguousType< - typename remove_reference<decltype(std::declval<T>()[0])>::type, N>(); + typename std::remove_reference<decltype(std::declval<T>()[0])>::type, + N>(); ExitOnError(MPI_Scatterv(&_v[0], &_counts[0], &_disps[0], mpi_type, &_lv[0], _recvCount, mpi_type, _root, MPI_COMM_WORLD)); @@ -138,19 +142,21 @@ template <typename T> void BCAST(T &_lT, const int &_root) { ExitOnError(MPI_Bcast(&_lT, 1, Type<T>(), _root, MPI_COMM_WORLD)); } -template <typename T> void BCAST(vector<T> &_lT, const int &_root) { +template <typename T> void BCAST(std::vector<T> &_lT, const int &_root) { ExitOnError(MPI_Bcast(&_lT[0], _lT.size(), Type<T>(), _root, MPI_COMM_WORLD)); } -template <typename T, int N> void BCAST(array<T, N> &_lT, const int &_root) { +template <typename T, int N> +void BCAST(std::array<T, N> &_lT, const int &_root) { ExitOnError(MPI_Bcast(&_lT[0], N, Type<T>(), _root, MPI_COMM_WORLD)); } template <typename T, int N> -void BCAST_CUSTOM(vector<T> &_lT, const int &_root) { +void BCAST_CUSTOM(std::vector<T> &_lT, const int &_root) { MPI_Datatype mpi_type = ContiguousType< - typename remove_reference<decltype(std::declval<T>()[0])>::type, N>(); + typename std::remove_reference<decltype(std::declval<T>()[0])>::type, + N>(); ExitOnError(MPI_Bcast(&_lT[0], _lT.size(), mpi_type, _root, MPI_COMM_WORLD)); @@ -166,8 +172,8 @@ void BCAST_CUSTOM(vector<T> &_lT, const int &_root) { template <typename T> void InitializeBuffers_NdNodalData( - vector<vector<T>> &_vT, const vector<vector<size_t>> &_connected_nodes, - const int &_d) { + std::vector<std::vector<T>> &_vT, + const std::vector<std::vector<size_t>> &_connected_nodes, const int &_d) { _vT.resize(_connected_nodes.size()); for (int ip = 0; ip < _connected_nodes.size(); ip++) _vT[ip].resize(_d * _connected_nodes[ip].size()); @@ -175,9 +181,9 @@ void InitializeBuffers_NdNodalData( template <typename T> void InitializeBuffers_VaryingdNodalData( - vector<vector<T>> &_vT, - const vector<vector<pair<int, int>>> &_connected_nodes, - const vector<vector<int>> &_varying_d_vec, const int &_d) { + std::vector<std::vector<T>> &_vT, + const std::vector<std::vector<std::pair<int, int>>> &_connected_nodes, + const std::vector<std::vector<int>> &_varying_d_vec, const int &_d) { _vT.resize(_connected_nodes.size()); for (int ip = 0; ip < _connected_nodes.size(); ip++) { int size = 0; @@ -189,8 +195,8 @@ void InitializeBuffers_VaryingdNodalData( } template <typename T> -void InitializeRecvBufferFromSendBuffer(vector<vector<T>> &_rcvT, - vector<vector<T>> _sndT) { +void InitializeRecvBufferFromSendBuffer(std::vector<std::vector<T>> &_rcvT, + std::vector<std::vector<T>> _sndT) { _rcvT.resize(_sndT.size()); for (int ip = 0; ip < _sndT.size(); ip++) _rcvT[ip].resize(_sndT[ip].size()); @@ -199,9 +205,9 @@ void InitializeRecvBufferFromSendBuffer(vector<vector<T>> &_rcvT, // when receiving processors and sending to processors // are same template <typename T> -void MPIExchangeBuffers_NonBlocking(vector<vector<T>> _sndT, - vector<vector<T>> &_rcvT, - vector<int> _connected_procs) { +void MPIExchangeBuffers_NonBlocking(std::vector<std::vector<T>> _sndT, + std::vector<std::vector<T>> &_rcvT, + std::vector<int> _connected_procs) { int idx_recv_tag = 99; // MPI_Request *mpi_send_requests; @@ -211,9 +217,9 @@ void MPIExchangeBuffers_NonBlocking(vector<vector<T>> _sndT, // mpi_recv_requests = new MPI_Request[_sndT.size()]; // mpi_wait_status = new MPI_Status[_sndT.size()]; - vector<MPI_Request> mpi_send_requests(_sndT.size()); - vector<MPI_Request> mpi_recv_requests(_sndT.size()); - vector<MPI_Status> mpi_wait_status(_sndT.size()); + std::vector<MPI_Request> mpi_send_requests(_sndT.size()); + std::vector<MPI_Request> mpi_recv_requests(_sndT.size()); + std::vector<MPI_Status> mpi_wait_status(_sndT.size()); for (int i_proc = 0; i_proc < _connected_procs.size(); i_proc++) { int p = _connected_procs[i_proc]; @@ -253,20 +259,20 @@ void MPIExchangeBuffers_NonBlocking(vector<vector<T>> _sndT, } template <typename T> -void MPIExchangeBuffers_NonBlocking(vector<T> _sndT, vector<T> &_rcvT, - vector<int> _sending_procs, - vector<int> _receiving_procs) { +void MPIExchangeBuffers_NonBlocking(std::vector<T> _sndT, std::vector<T> &_rcvT, + std::vector<int> _sending_procs, + std::vector<int> _receiving_procs) { int idx_recv_tag = 99; // MPI_Request *mpi_send_requests; // MPI_Request *mpi_recv_requests; // MPI_Status *mpi_send_status; // MPI_Status *mpi_recv_status; - vector<MPI_Request> mpi_send_requests(_sending_procs.size()); - vector<MPI_Request> mpi_recv_requests(_receiving_procs.size()); + std::vector<MPI_Request> mpi_send_requests(_sending_procs.size()); + std::vector<MPI_Request> mpi_recv_requests(_receiving_procs.size()); - vector<MPI_Status> mpi_send_status(_sending_procs.size()); - vector<MPI_Status> mpi_recv_status(_receiving_procs.size()); + std::vector<MPI_Status> mpi_send_status(_sending_procs.size()); + std::vector<MPI_Status> mpi_recv_status(_receiving_procs.size()); // mpi_send_requests = new MPI_Request[_sending_procs.size()]; // mpi_recv_requests = new MPI_Request[_receiving_procs.size()]; @@ -309,15 +315,15 @@ void MPIExchangeBuffers_NonBlocking(vector<T> _sndT, vector<T> &_rcvT, } template <typename T> -void MPIExchangeBuffers_NonBlocking(vector<T> _sndT, vector<T> &_rcvT, +void MPIExchangeBuffers_NonBlocking(std::vector<T> _sndT, std::vector<T> &_rcvT, const int &_total_ranks) { int idx_recv_tag = 109; - vector<MPI_Request> mpi_send_requests(_total_ranks - 1); - vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_send_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); - vector<MPI_Status> mpi_send_status(_total_ranks - 1); - vector<MPI_Status> mpi_recv_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_send_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_recv_status(_total_ranks - 1); int request_ctr = 0; @@ -346,15 +352,15 @@ void MPIExchangeBuffers_NonBlocking(vector<T> _sndT, vector<T> &_rcvT, } template <typename T> -void MPIExchangeBuffers_NonBlocking(const vector<vector<T>> &_sndT, - vector<vector<T>> &_rcvT, +void MPIExchangeBuffers_NonBlocking(const std::vector<std::vector<T>> &_sndT, + std::vector<std::vector<T>> &_rcvT, const int &_total_ranks) { int idx_recv_tag = 110; - vector<MPI_Request> mpi_send_requests(_total_ranks - 1); - vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_send_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); - vector<MPI_Status> mpi_send_status(_total_ranks - 1); - vector<MPI_Status> mpi_recv_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_send_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_recv_status(_total_ranks - 1); int request_ctr = 0; @@ -385,20 +391,21 @@ void MPIExchangeBuffers_NonBlocking(const vector<vector<T>> &_sndT, } template <typename T, int N> -void MPIExchangeBuffers_NonBlocking_CUSTOM(const vector<vector<T>> &_sndT, - vector<vector<T>> &_rcvT, - const int &_total_ranks) { +void MPIExchangeBuffers_NonBlocking_CUSTOM( + const std::vector<std::vector<T>> &_sndT, + std::vector<std::vector<T>> &_rcvT, const int &_total_ranks) { int idx_recv_tag = 999; - vector<MPI_Request> mpi_send_requests(_total_ranks - 1); - vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_send_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); - vector<MPI_Status> mpi_send_status(_total_ranks - 1); - vector<MPI_Status> mpi_recv_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_send_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_recv_status(_total_ranks - 1); int request_ctr = 0; MPI_Datatype mpi_type = ContiguousType< - typename remove_reference<decltype(std::declval<T>()[0])>::type, N>(); + typename std::remove_reference<decltype(std::declval<T>()[0])>::type, + N>(); for (int i_proc = 0; i_proc < _total_ranks; i_proc++) { if (i_proc != mpi_rank) { @@ -427,16 +434,17 @@ void MPIExchangeBuffers_NonBlocking_CUSTOM(const vector<vector<T>> &_sndT, } template <typename T> -void MPIExchangeBuffers_NonBlocking(const vector<T> &_sndT, vector<T> &_rcvT, +void MPIExchangeBuffers_NonBlocking(const std::vector<T> &_sndT, + std::vector<T> &_rcvT, const int &_total_ranks, - const vector<int> &_send_delimiters, - const vector<int> &_recv_delimiters) { + const std::vector<int> &_send_delimiters, + const std::vector<int> &_recv_delimiters) { int idx_recv_tag = 110; - vector<MPI_Request> mpi_send_requests(_total_ranks - 1); - vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_send_requests(_total_ranks - 1); + std::vector<MPI_Request> mpi_recv_requests(_total_ranks - 1); - vector<MPI_Status> mpi_send_status(_total_ranks - 1); - vector<MPI_Status> mpi_recv_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_send_status(_total_ranks - 1); + std::vector<MPI_Status> mpi_recv_status(_total_ranks - 1); int request_ctr = 0; @@ -480,18 +488,18 @@ void MPIExchangeBuffers_NonBlocking(const vector<T> &_sndT, vector<T> &_rcvT, // when receiving processors and sending to processors // are different template <typename T> -void MPIExchangeBuffers_NonBlocking(vector<vector<T>> _sndT, - vector<vector<T>> &_rcvT, - vector<int> _sending_procs, - vector<int> _receiving_procs) { +void MPIExchangeBuffers_NonBlocking(std::vector<std::vector<T>> _sndT, + std::vector<std::vector<T>> &_rcvT, + std::vector<int> _sending_procs, + std::vector<int> _receiving_procs) { int idx_recv_tag = 99; int p; - vector<MPI_Request> mpi_send_requests(_sending_procs.size()); - vector<MPI_Request> mpi_recv_requests(_receiving_procs.size()); + std::vector<MPI_Request> mpi_send_requests(_sending_procs.size()); + std::vector<MPI_Request> mpi_recv_requests(_receiving_procs.size()); - vector<MPI_Status> mpi_send_status(_sending_procs.size()); - vector<MPI_Status> mpi_recv_status(_receiving_procs.size()); + std::vector<MPI_Status> mpi_send_status(_sending_procs.size()); + std::vector<MPI_Status> mpi_recv_status(_receiving_procs.size()); // MPI_Request *mpi_send_requests; // MPI_Request *mpi_recv_requests; @@ -543,13 +551,13 @@ void MPIExchangeBuffers_NonBlocking(vector<vector<T>> _sndT, // delete [] mpi_recv_status; } -void MPIExchangeConnectedProcs(vector<int> _sndT, vector<int> &_rcvT, +void MPIExchangeConnectedProcs(std::vector<int> _sndT, std::vector<int> &_rcvT, const int &_size) { int idx_recv_tag = 99; - vector<MPI_Request> mpi_send_requests(_sndT.size()); - vector<MPI_Request> mpi_recv_requests(_sndT.size()); - vector<MPI_Status> mpi_wait_status(_sndT.size()); + std::vector<MPI_Request> mpi_send_requests(_sndT.size()); + std::vector<MPI_Request> mpi_recv_requests(_sndT.size()); + std::vector<MPI_Status> mpi_wait_status(_sndT.size()); for (int i_proc = 0; i_proc < _size; i_proc++) { int p = i_proc; @@ -581,10 +589,10 @@ void MPIExchangeConnectedProcs(vector<int> _sndT, vector<int> &_rcvT, } template <typename T> -void BoostMPIExchange_T_Blocking(vector<vector<T>> _send_buff, - vector<vector<T>> &_recv_buff, - vector<int> _sending_procs, - vector<int> _receiving_procs) { +void BoostMPIExchange_T_Blocking(std::vector<std::vector<T>> _send_buff, + std::vector<std::vector<T>> &_recv_buff, + std::vector<int> _sending_procs, + std::vector<int> _receiving_procs) { mpi::communicator local; int mpi_tag = 99; @@ -601,9 +609,9 @@ void BoostMPIExchange_T_Blocking(vector<vector<T>> _send_buff, template <typename MeshClass, typename Atom, int DIM> void PackBuffers_AtomsWeights(const MeshClass &_mesh, - vector<vector<double>> &_send_buff, - vector<vector<double>> &_recv_buff, - const vector<Atom> &_atoms) { + std::vector<std::vector<double>> &_send_buff, + std::vector<std::vector<double>> &_recv_buff, + const std::vector<Atom> &_atoms) { int _buffer_dim = 1; InitializeBuffers_NdNodalData<double>(_send_buff, _mesh.connected_nodes_, @@ -625,8 +633,8 @@ void PackBuffers_AtomsWeights(const MeshClass &_mesh, // Pack Buffers of repatoms forces template <typename MeshClass, typename AtomContainer, int DIM> void PackBuffers_AtomsForces(MeshClass _mesh, - vector<vector<double>> &_send_buff, - vector<vector<double>> &_recv_buff, + std::vector<std::vector<double>> &_send_buff, + std::vector<std::vector<double>> &_recv_buff, AtomContainer _atoms) { int _buffer_dim = DIM; @@ -652,10 +660,10 @@ void PackBuffers_AtomsForces(MeshClass _mesh, } template <typename Atom, typename Point_d, int DIM> void PackSendBuffers_DependentBonds( - const vector<Atom> &_atoms, const vector<int> &_connected_procs, - const vector<vector<pair<int, int>>> &_connected_node_ids, - vector<vector<double>> &_neighbour_bonds_weights_send_buffer, - vector<vector<int>> &_number_of_neighbour_bonds_send_buffer) { + const std::vector<Atom> &_atoms, const std::vector<int> &_connected_procs, + const std::vector<std::vector<std::pair<int, int>>> &_connected_node_ids, + std::vector<std::vector<double>> &_neighbour_bonds_weights_send_buffer, + std::vector<std::vector<int>> &_number_of_neighbour_bonds_send_buffer) { _neighbour_bonds_weights_send_buffer.resize(_connected_procs.size()); _number_of_neighbour_bonds_send_buffer.resize(_connected_procs.size()); @@ -691,9 +699,9 @@ void PackSendBuffers_DependentBonds( } template <typename MeshClass, typename Atom, int DIM> -void UnPackBuffers_AtomsWeights(const MeshClass &_mesh, - const vector<vector<double>> &_recv_buff, - vector<Atom> &_atoms) { +void UnPackBuffers_AtomsWeights( + const MeshClass &_mesh, const std::vector<std::vector<double>> &_recv_buff, + std::vector<Atom> &_atoms) { size_t recv_buff_ctr, id; for (int i = 0; i < _mesh.connected_node_procs_.size(); i++) { @@ -709,7 +717,7 @@ void UnPackBuffers_AtomsWeights(const MeshClass &_mesh, // UnPack Buffers of repatoms forces template <typename MeshClass, typename AtomContainer, int DIM> void UnPackBuffers_AtomsForces(MeshClass _mesh, - vector<vector<double>> &_recv_buff, + std::vector<std::vector<double>> &_recv_buff, AtomContainer &_atoms) { int recv_buff_ctr; @@ -732,14 +740,15 @@ void UnPackBuffers_AtomsForces(MeshClass _mesh, template <typename Atom, typename Point_d, typename Vector_d, int DIM> void UnPackRecvBuffers_DependentBonds( - vector<Atom> &_atoms, - const vector<vector<double>> &_neighbour_bonds_weights_recv_buffer, - const vector<vector<int>> &_number_of_neighbour_bonds_recv_buffer, - const vector<vector<pair<int, int>>> &_connected_node_ids) { + std::vector<Atom> &_atoms, + const std::vector<std::vector<double>> + &_neighbour_bonds_weights_recv_buffer, + const std::vector<std::vector<int>> &_number_of_neighbour_bonds_recv_buffer, + const std::vector<std::vector<std::pair<int, int>>> &_connected_node_ids) { int repatom_id; int recv_buff_ctr; - pair<Point_d, Point_d> received_bond; + std::pair<Point_d, Point_d> received_bond; Point_d p1, p2; Vector_d received_force; @@ -772,7 +781,7 @@ void UnPackRecvBuffers_DependentBonds( received_bond = make_pair(p1, p2); added_received_bond = - Utilities::ADD_TO_CONTAINER_UNIQUE<pair<Point_d, Point_d>>( + Utilities::ADD_TO_CONTAINER_UNIQUE<std::pair<Point_d, Point_d>>( _atoms[repatom_id].dependent_neighbour_bonds_, received_bond, received_bond_idx); @@ -798,15 +807,15 @@ template <typename T> void boostBroadcast(T &_t) { } } template <typename T> -void BoostMPIExchange_T_NonBlocking(const vector<vector<T>> &_send_buff, - vector<vector<T>> &_recv_buff, - const vector<int> &_sending_procs, - const vector<int> &_receiving_procs, - bool print_messages = false) { +void BoostMPIExchange_T_NonBlocking( + const std::vector<std::vector<T>> &_send_buff, + std::vector<std::vector<T>> &_recv_buff, + const std::vector<int> &_sending_procs, + const std::vector<int> &_receiving_procs, bool print_messages = false) { mpi::communicator local; - vector<mpi::request> mpi_send_requests(_sending_procs.size()); - vector<mpi::request> mpi_recv_requests(_receiving_procs.size()); + std::vector<mpi::request> mpi_send_requests(_sending_procs.size()); + std::vector<mpi::request> mpi_recv_requests(_receiving_procs.size()); int mpi_tag = 99; @@ -815,7 +824,7 @@ void BoostMPIExchange_T_NonBlocking(const vector<vector<T>> &_send_buff, mpi_recv_requests[i_proc] = local.irecv(p, mpi_tag, _recv_buff[i_proc]); if (print_messages) { - cout << mpi_rank << " posted non-blocking receives" << endl; + std::cout << mpi_rank << " posted non-blocking receives" << std::endl; } } @@ -824,7 +833,7 @@ void BoostMPIExchange_T_NonBlocking(const vector<vector<T>> &_send_buff, mpi_send_requests[i_proc] = local.isend(p, mpi_tag, _send_buff[i_proc]); if (print_messages) { - cout << mpi_rank << " posted non-blocking sends" << endl; + std::cout << mpi_rank << " posted non-blocking sends" << std::endl; } } mpi::wait_all(mpi_send_requests.begin(), mpi_send_requests.end()); @@ -833,14 +842,14 @@ void BoostMPIExchange_T_NonBlocking(const vector<vector<T>> &_send_buff, } template <typename T> -void BoostMPIExchange_T_NonBlocking1D(vector<T> _send_buff, - vector<T> &_recv_buff, - vector<int> _sending_procs, - vector<int> _receiving_procs) { +void BoostMPIExchange_T_NonBlocking1D(std::vector<T> _send_buff, + std::vector<T> &_recv_buff, + std::vector<int> _sending_procs, + std::vector<int> _receiving_procs) { mpi::communicator local; - vector<mpi::request> mpi_send_requests(_sending_procs.size()); - vector<mpi::request> mpi_recv_requests(_receiving_procs.size()); + std::vector<mpi::request> mpi_send_requests(_sending_procs.size()); + std::vector<mpi::request> mpi_recv_requests(_receiving_procs.size()); int mpi_tag = 99; for (int i_proc = 0; i_proc < _sending_procs.size(); i_proc++) { @@ -858,18 +867,18 @@ void BoostMPIExchange_T_NonBlocking1D(vector<T> _send_buff, mpi::wait_all(mpi_recv_requests.begin(), mpi_recv_requests.end()); } template <typename T> -void BoostMPIExchange_T_NonBlockingArchive(vector<T> _send_buff, - vector<T> &_recv_buff, - vector<int> _sending_procs, - vector<int> _receiving_procs) { +void BoostMPIExchange_T_NonBlockingArchive(std::vector<T> _send_buff, + std::vector<T> &_recv_buff, + std::vector<int> _sending_procs, + std::vector<int> _receiving_procs) { mpi::communicator local; - vector<mpi::request> mpi_send_requests(_sending_procs.size()); - vector<mpi::request> mpi_recv_requests(_receiving_procs.size()); + std::vector<mpi::request> mpi_send_requests(_sending_procs.size()); + std::vector<mpi::request> mpi_recv_requests(_receiving_procs.size()); int mpi_tag = 99; - // vector<mpi::packed_oarchive> oar_vector(_sending_procs.size()); + // std::vector<mpi::packed_oarchive> oar_vector(_sending_procs.size()); for (int i_proc = 0; i_proc < _sending_procs.size(); i_proc++) { int p = _sending_procs[i_proc]; diff --git a/src/common/sorters.h b/src/common/sorters.h index 91a7a67da..b8a233b67 100644 --- a/src/common/sorters.h +++ b/src/common/sorters.h @@ -11,9 +11,6 @@ #include <stlib/ads/utility/ParseOptionsArguments.h> #include <stlib/geom/orq/SpatialIndexMortonUniform.h> -using namespace std; -// using namespace stlib; - namespace Sorters { template <class Point, class Box, int DIM> class Base { diff --git a/src/common/utilities.h b/src/common/utilities.h index ff2fa3376..5264cd2e5 100644 --- a/src/common/utilities.h +++ b/src/common/utilities.h @@ -5,12 +5,11 @@ #pragma once #include "StandardHeaders.h" -using namespace std; namespace Utilities { -vector<double> CROSS(vector<double> _v1, vector<double> _v2) { - vector<double> _vc; +std::vector<double> CROSS(std::vector<double> _v1, std::vector<double> _v2) { + std::vector<double> _vc; _vc.resize(3); _vc[0] = _v1[1] * _v2[2] - _v1[2] * _v2[1]; @@ -19,7 +18,7 @@ vector<double> CROSS(vector<double> _v1, vector<double> _v2) { return _vc; } -double DISTANCE(vector<double> _v1, vector<double> _v2) { +double DISTANCE(std::vector<double> _v1, std::vector<double> _v2) { double dist = 0.0; for (int d = 0; d < _v1.size(); d++) { dist += (_v1[d] - _v2[d]) * (_v1[d] - _v2[d]); @@ -27,7 +26,7 @@ double DISTANCE(vector<double> _v1, vector<double> _v2) { return sqrt(dist); } -double MAGNITUDE(vector<double> _v) { +double MAGNITUDE(std::vector<double> _v) { double mag = 0.0; for (int d = 0; d < _v.size(); d++) { mag += _v[d] * _v[d]; @@ -35,8 +34,8 @@ double MAGNITUDE(vector<double> _v) { return sqrt(mag); } -vector<double> NORMALIZE(vector<double> _v) { - vector<double> _vn; +std::vector<double> NORMALIZE(std::vector<double> _v) { + std::vector<double> _vn; _vn.resize(_v.size()); double mag = MAGNITUDE(_v); @@ -49,8 +48,8 @@ vector<double> NORMALIZE(vector<double> _v) { } template <int DIM> -array<array<int, DIM>, DIM + 1> CREATE_INDICES_PERMUTATION() { - array<array<int, DIM>, DIM + 1> sideIndices; +std::array<std::array<int, DIM>, DIM + 1> CREATE_INDICES_PERMUTATION() { + std::array<std::array<int, DIM>, DIM + 1> sideIndices; for (int i = 0; i < DIM + 1; ++i) { int index = 0; for (int j = 0; j < DIM + 1; ++j) { @@ -63,7 +62,7 @@ array<array<int, DIM>, DIM + 1> CREATE_INDICES_PERMUTATION() { return sideIndices; } template <int DIM> -void CREATE_INDICES_PERMUTATION(vector<vector<int>> &_sideIndices) { +void CREATE_INDICES_PERMUTATION(std::vector<std::vector<int>> &_sideIndices) { _sideIndices.resize(DIM + 1); for (int i = 0; i < DIM + 1; ++i) { @@ -79,16 +78,16 @@ void CREATE_INDICES_PERMUTATION(vector<vector<int>> &_sideIndices) { } template <int DIM> -array<array<int, 2>, ((DIM + 1) * DIM) / 2> +std::array<std::array<int, 2>, ((DIM + 1) * DIM) / 2> GENERATE_NODE_INDICES_PERMUTATION() { - array<array<int, 2>, (DIM + 1) * DIM / 2> nodeIndices; + std::array<std::array<int, 2>, (DIM + 1) * DIM / 2> nodeIndices; int index = 0; for (int nodeNumber = 0; nodeNumber < DIM + 1; ++nodeNumber) { for (int otherNodeNumber = nodeNumber + 1; otherNodeNumber < DIM + 1; ++otherNodeNumber) { - nodeIndices[index] = (array<int, 2>){{nodeNumber, otherNodeNumber}}; + nodeIndices[index] = (std::array<int, 2>){{nodeNumber, otherNodeNumber}}; ++index; } } @@ -96,7 +95,8 @@ GENERATE_NODE_INDICES_PERMUTATION() { } template <int DIM> -void GENERATE_NODE_INDICES_PERMUTATION(vector<vector<int>> &_nodeIndices) { +void GENERATE_NODE_INDICES_PERMUTATION( + std::vector<std::vector<int>> &_nodeIndices) { _nodeIndices.resize((DIM + 1) * DIM / 2); int index = 0; @@ -123,12 +123,13 @@ template <class Iter, class T> Iter BINARY_FIND(Iter begin, Iter end, T val) { } template <class Point, class Box, int DIM> -void DISCRETIZE_CGAL_BOX(vector<int> NoofCoarseBoxes, Box domain) { - cout << "nothing to do" << endl; +void DISCRETIZE_CGAL_BOX(std::vector<int> NoofCoarseBoxes, Box domain) { + std::cout << "nothing to do" << std::endl; } // O(n) checking. Implement with kd-tree later on -template <class T> bool CHECK_IF_IN_CONTAINER(vector<T> container, T item) { +template <class T> +bool CHECK_IF_IN_CONTAINER(std::vector<T> container, T item) { bool present = false; for (T &t : container) { if (t == item) { @@ -140,7 +141,7 @@ template <class T> bool CHECK_IF_IN_CONTAINER(vector<T> container, T item) { } template <class T> -bool CHECK_IF_IN_CONTAINER(vector<T> container, T item, int &idx) { +bool CHECK_IF_IN_CONTAINER(std::vector<T> container, T item, int &idx) { bool present = false; idx = 0; @@ -155,7 +156,7 @@ bool CHECK_IF_IN_CONTAINER(vector<T> container, T item, int &idx) { } // template<class T> -// bool CHECK_IF_IN_CONTAINER(vector<T> container, T item, int &idx) +// bool CHECK_IF_IN_CONTAINER(std::vector<T> container, T item, int &idx) // { // bool present = false; // idx = 0; @@ -170,8 +171,8 @@ bool CHECK_IF_IN_CONTAINER(vector<T> container, T item, int &idx) { // } template <class T> -void ARRANGE_VECTOR_INPUT_INDICES(vector<T> &_v, vector<int> _idxs) { - vector<T> v_copy(_v.size()); +void ARRANGE_VECTOR_INPUT_INDICES(std::vector<T> &_v, std::vector<int> _idxs) { + std::vector<T> v_copy(_v.size()); for (int i = 0; i < _v.size(); i++) v_copy[i] = _v[i]; @@ -179,7 +180,8 @@ void ARRANGE_VECTOR_INPUT_INDICES(vector<T> &_v, vector<int> _idxs) { _v[_idxs[i]] = v_copy[i]; } } -template <class T> bool ADD_TO_CONTAINER_UNIQUE(vector<T> &container, T item) { +template <class T> +bool ADD_TO_CONTAINER_UNIQUE(std::vector<T> &container, T item) { bool present = CHECK_IF_IN_CONTAINER<T>(container, item); if (!present) { container.push_back(item); @@ -189,7 +191,7 @@ template <class T> bool ADD_TO_CONTAINER_UNIQUE(vector<T> &container, T item) { } template <class T> -bool ADD_TO_CONTAINER_UNIQUE(vector<T> &container, T item, int &idx) { +bool ADD_TO_CONTAINER_UNIQUE(std::vector<T> &container, T item, int &idx) { bool present = CHECK_IF_IN_CONTAINER<T>(container, item, idx); if (!present) { container.push_back(item); @@ -200,14 +202,14 @@ bool ADD_TO_CONTAINER_UNIQUE(vector<T> &container, T item, int &idx) { } template <class T> -void ADD_TO_CONTAINER_UNIQUE_VOID(vector<T> &container, T item) { +void ADD_TO_CONTAINER_UNIQUE_VOID(std::vector<T> &container, T item) { bool present = CHECK_IF_IN_CONTAINER<T>(container, item); if (!present) { container.push_back(item); } } // template<class T> -// bool ADD_TO_CONTAINER_UNIQUE(vector<T> &container, T item, int &idx) +// bool ADD_TO_CONTAINER_UNIQUE(std::vector<T> &container, T item, int &idx) // { // bool present = CHECK_IF_IN_CONTAINER<T>(container, item, idx); // if(!present) @@ -219,8 +221,8 @@ void ADD_TO_CONTAINER_UNIQUE_VOID(vector<T> &container, T item) { // return (!present); // } -template <class T> int REMOVE_FROM_VECTOR(vector<T> &_v, const T &_x) { - typename vector<T>::iterator position = find(_v.begin(), _v.end(), _x); +template <class T> int REMOVE_FROM_VECTOR(std::vector<T> &_v, const T &_x) { + typename std::vector<T>::iterator position = find(_v.begin(), _v.end(), _x); int return_position; @@ -235,9 +237,9 @@ template <class T> int REMOVE_FROM_VECTOR(vector<T> &_v, const T &_x) { } template <class T> -int REMOVE_FROM_MAPPED_VECTOR(vector<T> &_v, const vector<T> &_map, +int REMOVE_FROM_MAPPED_VECTOR(std::vector<T> &_v, const std::vector<T> &_map, const T &_idx) { - vector<T> _idv; + std::vector<T> _idv; for (T v_i : _v) { _idv.push_back(_map[v_i]); } @@ -245,7 +247,7 @@ int REMOVE_FROM_MAPPED_VECTOR(vector<T> &_v, const vector<T> &_map, int return_position = REMOVE_FROM_VECTOR<T>(_idv, _idx); if (return_position != -1) { - typename vector<T>::iterator position = _v.begin() + return_position; + typename std::vector<T>::iterator position = _v.begin() + return_position; _v.erase(position); } @@ -253,14 +255,14 @@ int REMOVE_FROM_MAPPED_VECTOR(vector<T> &_v, const vector<T> &_map, } template <typename T> -void FIND_COMMON_VALUES(vector<T> _v1, vector<T> _v2, - vector<T> &_v1_intersection_v2) { +void FIND_COMMON_VALUES(std::vector<T> _v1, std::vector<T> _v2, + std::vector<T> &_v1_intersection_v2) { sort(_v1.begin(), _v1.end()); sort(_v2.begin(), _v2.end()); - vector<T> v(_v1.size() + _v2.size()); + std::vector<T> v(_v1.size() + _v2.size()); - typename vector<T>::iterator it, st; + typename std::vector<T>::iterator it, st; it = set_intersection(_v1.begin(), _v1.end(), _v2.begin(), _v2.end(), v.begin()); @@ -271,11 +273,12 @@ void FIND_COMMON_VALUES(vector<T> _v1, vector<T> _v2, } template <typename T> -void FIND_COMMON_VALUES_MAPPED(vector<T> _v1, vector<T> _v2, - vector<T> &_v1_intersection_v2, - const vector<T> &_map, const vector<T> &_map_r) { - vector<T> _idv1; - vector<T> _idv2; +void FIND_COMMON_VALUES_MAPPED(std::vector<T> _v1, std::vector<T> _v2, + std::vector<T> &_v1_intersection_v2, + const std::vector<T> &_map, + const std::vector<T> &_map_r) { + std::vector<T> _idv1; + std::vector<T> _idv2; for (T v1_i : _v1) { _idv1.push_back(_map[v1_i]); @@ -288,9 +291,9 @@ void FIND_COMMON_VALUES_MAPPED(vector<T> _v1, vector<T> _v2, sort(_idv1.begin(), _idv1.end()); sort(_idv2.begin(), _idv2.end()); - vector<T> idv(_idv1.size() + _idv2.size()); + std::vector<T> idv(_idv1.size() + _idv2.size()); - typename vector<T>::iterator it, st; + typename std::vector<T>::iterator it, st; it = set_intersection(_idv1.begin(), _idv1.end(), _idv2.begin(), _idv2.end(), idv.begin()); @@ -301,14 +304,14 @@ void FIND_COMMON_VALUES_MAPPED(vector<T> _v1, vector<T> _v2, } template <typename T> -void FIND_COMMON_VALUES_DOUBLE_MAPPED(vector<T> _v1, vector<T> _v2, - vector<T> &_v1_intersection_v2, - const vector<T> &_map_1, - const vector<T> &_map_2, - const vector<T> &_map_1_r, - const vector<T> &_map_2_r) { - vector<T> _idv1; - vector<T> _idv2; +void FIND_COMMON_VALUES_DOUBLE_MAPPED(std::vector<T> _v1, std::vector<T> _v2, + std::vector<T> &_v1_intersection_v2, + const std::vector<T> &_map_1, + const std::vector<T> &_map_2, + const std::vector<T> &_map_1_r, + const std::vector<T> &_map_2_r) { + std::vector<T> _idv1; + std::vector<T> _idv2; for (T v1_i : _v1) { _idv1.push_back(_map_2[_map_1[v1_i]]); @@ -321,9 +324,9 @@ void FIND_COMMON_VALUES_DOUBLE_MAPPED(vector<T> _v1, vector<T> _v2, sort(_idv1.begin(), _idv1.end()); sort(_idv2.begin(), _idv2.end()); - vector<T> idv(_idv1.size() + _idv2.size()); + std::vector<T> idv(_idv1.size() + _idv2.size()); - typename vector<T>::iterator it, st; + typename std::vector<T>::iterator it, st; it = set_intersection(_idv1.begin(), _idv1.end(), _idv2.begin(), _idv2.end(), idv.begin()); @@ -353,9 +356,9 @@ T MOST_COMMON(InputIt begin, InputIt end) { } // template<typename T> -// vector<int> TAG_SORT(const std::vector<T>& v) +// std::vector<int> TAG_SORT(const std::vector<T>& v) // { -// vector<std::size_t> result(v.size()); +// std::vector<std::size_t> result(v.size()); // iota(std::begin(result), std::end(result), 0); // sort(std::begin(result), std::end(result), // [&v](const int & lhs, const int & rhs) @@ -373,16 +376,16 @@ void CONVERT_CGAL_TO_LOCALPOINT(LocalPoint &outputp, Point &p) { } template <int D, class LocalPoint, class Point> -void CONVERT_CGAL_TO_LOCALPOINT_VECTOR(vector<LocalPoint> &outputps, - vector<Point> &ps) { +void CONVERT_CGAL_TO_LOCALPOINT_VECTOR(std::vector<LocalPoint> &outputps, + std::vector<Point> &ps) { for (int i = 0; i < ps.size(); i++) { CONVERT_CGAL_TO_LOCALPOINT<D, LocalPoint, Point>(outputps[i], ps[i]); } } template <class T> -void COPY_CONTAINER_VALUE_OF_TYPE_T(vector<T> _input_container, - vector<T> &_output_container) { +void COPY_CONTAINER_VALUE_OF_TYPE_T(std::vector<T> _input_container, + std::vector<T> &_output_container) { _output_container.resize(0); for (int i = 0; i < _input_container.size(); i++) { _output_container.push_back(_input_container[i]); @@ -390,7 +393,7 @@ void COPY_CONTAINER_VALUE_OF_TYPE_T(vector<T> _input_container, } template <class T, int DIM> -void COMPUTE_BARYCENTER_SIMPLEX(vector<T> _points, T &_barycenter) { +void COMPUTE_BARYCENTER_SIMPLEX(std::vector<T> _points, T &_barycenter) { _barycenter.Zero(); for (T &point : _points) { @@ -401,8 +404,8 @@ void COMPUTE_BARYCENTER_SIMPLEX(vector<T> _points, T &_barycenter) { } inline void GET_ARRAYS_3(const Eigen::Matrix<double, 3, 3> &M, - array<double, 3> &A, array<double, 3> &B, - array<double, 3> &C) { + std::array<double, 3> &A, std::array<double, 3> &B, + std::array<double, 3> &C) { for (int i = 0; i != 3; ++i) { A[i] = M(i, 0); B[i] = M(i, 1); @@ -411,11 +414,11 @@ inline void GET_ARRAYS_3(const Eigen::Matrix<double, 3, 3> &M, } template <int DIM> -void MultiplyVectorsEigen(vector<vector<double>> &, +void MultiplyVectorsEigen(std::vector<std::vector<double>> &, Eigen::Matrix<double, DIM, DIM>); template <> -void MultiplyVectorsEigen<2>(vector<vector<double>> &_bv, +void MultiplyVectorsEigen<2>(std::vector<std::vector<double>> &_bv, Eigen::Matrix<double, 2, 2> _F) { for (int d = 0; d < 2; d++) { Eigen::Vector2d v, dv; @@ -428,7 +431,7 @@ void MultiplyVectorsEigen<2>(vector<vector<double>> &_bv, } template <> -void MultiplyVectorsEigen<3>(vector<vector<double>> &_bv, +void MultiplyVectorsEigen<3>(std::vector<std::vector<double>> &_bv, Eigen::Matrix<double, 3, 3> _F) { for (int d = 0; d < 3; d++) { Eigen::Vector3d v, dv; @@ -443,13 +446,13 @@ void MultiplyVectorsEigen<3>(vector<vector<double>> &_bv, template <int DIM> Eigen::Matrix<double, DIM, DIM> -computeDeformationGradientFromUndeformedAndDeformedVectors( - vector<vector<double>>, vector<vector<double>>); + computeDeformationGradientFromUndeformedAndDeformedVectors( + std::vector<std::vector<double>>, std::vector<std::vector<double>>); template <> Eigen::Matrix<double, 3, 3> computeDeformationGradientFromUndeformedAndDeformedVectors<3>( - vector<vector<double>> u, vector<vector<double>> d) { + std::vector<std::vector<double>> u, std::vector<std::vector<double>> d) { // Bugs prone direct formula for A*B.inv() // TO-DO - generalize it with Eigen @@ -501,7 +504,7 @@ computeDeformationGradientFromUndeformedAndDeformedVectors<3>( template <> Eigen::Matrix<double, 2, 2> computeDeformationGradientFromUndeformedAndDeformedVectors<2>( - vector<vector<double>> u, vector<vector<double>> d) { + std::vector<std::vector<double>> u, std::vector<std::vector<double>> d) { // Bugs prone direct formula for A*B.inv() // TO-DO - generalize it with Eigen @@ -567,7 +570,7 @@ void tokenize(const std::string &str, const std::string &delimiters, } } -template <class T> T convertString(const string &str) { +template <class T> T convertString(const std::string &str) { std::stringstream ss; ss << str; T returnVal; @@ -575,7 +578,7 @@ template <class T> T convertString(const string &str) { return returnVal; } -template <> float convertString<float>(const string &str) { +template <> float convertString<float>(const std::string &str) { if (strcmp(str.c_str(), "nan") == 0) { // printf("Parsed a nan\n"); return std::numeric_limits<float>::quiet_NaN(); @@ -588,7 +591,7 @@ template <> float convertString<float>(const string &str) { } } -template <> double convertString<double>(const string &str) { +template <> double convertString<double>(const std::string &str) { if (strcmp(str.c_str(), "nan") == 0) { // printf("Parsed a nan\n"); return std::numeric_limits<double>::quiet_NaN(); @@ -601,32 +604,33 @@ template <> double convertString<double>(const string &str) { } } -bool string2bool(string s) { - string t = "true"; - string f = "false"; +bool string2bool(std::string s) { + std::string t = "true"; + std::string f = "false"; size_t found_t = s.find(t); size_t found_f = s.find(f); - if (found_t != string::npos) + if (found_t != std::string::npos) return true; - else if (found_f != string::npos) + else if (found_f != std::string::npos) return false; else { - cout << "Please define boolean values as 'true' or 'false' in input file" - << endl; + std::cout + << "Please define boolean values as 'true' or 'false' in input file" + << std::endl; exit(0); } } -std::array<double, 3> string2Doublearray(string s) { +std::array<double, 3> string2Doublearray(std::string s) { std::size_t offset = 0; std::size_t offset2 = 0; - array<double, 3> tmpArr; + std::array<double, 3> tmpArr; // offset contains the char length of the double --> offset+offset2 - tmpArr[0] = stod(&s[0], &offset); - tmpArr[1] = stod(&s[offset + 2], &offset2); - tmpArr[2] = stod(&s[offset + offset2 + 4], &offset2); + tmpArr[0] = std::stod(&s[0], &offset); + tmpArr[1] = std::stod(&s[offset + 2], &offset2); + tmpArr[2] = std::stod(&s[offset + offset2 + 4], &offset2); return tmpArr; } -} // namespace FileUtilities \ No newline at end of file +} // namespace FileUtilities diff --git a/src/debuggers/debug_interprocatoms.ipp b/src/debuggers/debug_interprocatoms.ipp index 23961db8b..2d331d4d9 100644 --- a/src/debuggers/debug_interprocatoms.ipp +++ b/src/debuggers/debug_interprocatoms.ipp @@ -6,9 +6,9 @@ template <typename point_d, typename atom, typename mesh_d, int DIM> void debuggers::CheckInterProcConnectedAtoms_location( - const vector<atom> &_atoms, const mesh_d &_local_mesh) { - vector<vector<point_d>> send_coordinates; - vector<vector<point_d>> recv_coordinates; + const std::vector<atom> &_atoms, const mesh_d &_local_mesh) { + std::vector<std::vector<point_d>> send_coordinates; + std::vector<std::vector<point_d>> recv_coordinates; send_coordinates.resize(_local_mesh.ConnectedProcs.size()); recv_coordinates.resize(_local_mesh.ConnectedProcs.size()); @@ -34,11 +34,12 @@ void debuggers::CheckInterProcConnectedAtoms_location( i_node++) { if (!(send_coordinates[i_proc][i_node] == recv_coordinates[i_proc][i_node])) { - cout << "rank = " << mpi_rank - << " encountered problem with interproc atom." << endl; - cout << "same atom has different locations in " << mpi_rank - << " and connected through " << _local_mesh.ConnectedProcs[i_proc] - << ". Exiting..." << endl; + std::cout << "rank = " << mpi_rank + << " encountered problem with interproc atom." << std::endl; + std::cout << "same atom has different locations in " << mpi_rank + << " and connected through " + << _local_mesh.ConnectedProcs[i_proc] << ". Exiting..." + << std::endl; exit(0); } } @@ -46,10 +47,10 @@ void debuggers::CheckInterProcConnectedAtoms_location( } template <typename atom, typename mesh_d, int DIM> -void debuggers::CheckInterProcConnectedAtoms(const vector<atom> &_atoms, +void debuggers::CheckInterProcConnectedAtoms(const std::vector<atom> &_atoms, const mesh_d &_local_mesh) { - vector<vector<atom>> send_atoms; - vector<vector<atom>> recv_atoms; + std::vector<std::vector<atom>> send_atoms; + std::vector<std::vector<atom>> recv_atoms; send_atoms.resize(_local_mesh.ConnectedProcs.size()); recv_atoms.resize(_local_mesh.ConnectedProcs.size()); @@ -74,20 +75,22 @@ void debuggers::CheckInterProcConnectedAtoms(const vector<atom> &_atoms, for (int i_node = 0; i_node < _local_mesh.ConnectedNodes[i_proc].size(); i_node++) { if (!(send_atoms[i_proc][i_node] == recv_atoms[i_proc][i_node])) { - cout << "rank = " << mpi_rank - << " encountered problem with interproc atom. " - << _local_mesh.ConnectedNodes[i_proc][i_node].second << endl; - cout << "same atom has different locations in " << mpi_rank - << " and connected through " << _local_mesh.ConnectedProcs[i_proc] - << endl; - cout << "local id in owned rank " - << _local_mesh.ConnectedNodes[i_proc][i_node].second << endl; - cout << send_atoms[i_proc][i_node].velocity_[0] << " , " - << send_atoms[i_proc][i_node].velocity_[1] << " ; " - << recv_atoms[i_proc][i_node].velocity_[0] << " , " - << recv_atoms[i_proc][i_node].velocity_[1] << endl; - - cout << time_step << " , " << alpha << endl; + std::cout << "rank = " << mpi_rank + << " encountered problem with interproc atom. " + << _local_mesh.ConnectedNodes[i_proc][i_node].second + << std::endl; + std::cout << "same atom has different locations in " << mpi_rank + << " and connected through " + << _local_mesh.ConnectedProcs[i_proc] << std::endl; + std::cout << "local id in owned rank " + << _local_mesh.ConnectedNodes[i_proc][i_node].second + << std::endl; + std::cout << send_atoms[i_proc][i_node].velocity_[0] << " , " + << send_atoms[i_proc][i_node].velocity_[1] << " ; " + << recv_atoms[i_proc][i_node].velocity_[0] << " , " + << recv_atoms[i_proc][i_node].velocity_[1] << std::endl; + + std::cout << time_step << " , " << alpha << std::endl; exit(0); } diff --git a/src/debuggers/debuggers.h b/src/debuggers/debuggers.h index 6890e09b4..467985319 100644 --- a/src/debuggers/debuggers.h +++ b/src/debuggers/debuggers.h @@ -3,15 +3,13 @@ #include "StandardHeaders.h" #include "variables.h" -using namespace std; - namespace debuggers { template <typename point_d, typename atom, typename mesh_d, int DIM> -void CheckInterProcConnectedAtoms_location(const vector<atom> &, +void CheckInterProcConnectedAtoms_location(const std::vector<atom> &, const mesh_d &); template <typename atom, typename mesh_d, int DIM> -void CheckInterProcConnectedAtoms(const vector<atom> &, const mesh_d &); +void CheckInterProcConnectedAtoms(const std::vector<atom> &, const mesh_d &); } // namespace debuggers -#include "debug_interprocatoms.ipp" \ No newline at end of file +#include "debug_interprocatoms.ipp" diff --git a/src/geometry/mapping.h b/src/geometry/mapping.h index dc64be28b..84c85dc1f 100644 --- a/src/geometry/mapping.h +++ b/src/geometry/mapping.h @@ -23,8 +23,8 @@ void projectSimplexEdgesOnBasis(const Eigen::Matrix<double, K, K> &_edges, } template <int K> -void getBasisFromProjectors(const array<point<K>, K> &_edges, - const array<point<K>, K> &_n, +void getBasisFromProjectors(const std::array<point<K>, K> &_edges, + const std::array<point<K>, K> &_n, Eigen::Matrix<double, K, K> &_B, int &_nV) { Eigen::Matrix<double, K, K> s; Eigen::Matrix<double, K, K> n; @@ -38,10 +38,10 @@ void getBasisFromProjectors(const array<point<K>, K> &_edges, } } if (abs(n.determinant()) < 1.0e-4) { - cout << "possibly singular matrix " << endl; - cout << n << endl; - cout << ni << endl; - cout << s << endl; + std::cout << "possibly singular matrix " << std::endl; + std::cout << n << std::endl; + std::cout << ni << std::endl; + std::cout << s << std::endl; } _B = s * n.inverse(); @@ -59,8 +59,8 @@ void projectSimplexEdgesOnBasis(const Eigen::Matrix<double, K, K> &_edges, template <int D> void projectEdgeOnBasis(const Eigen::Matrix<double, D, D> &_basis, - const array<double, D> &_edge, - array<double, D> &_projector) { + const std::array<double, D> &_edge, + std::array<double, D> &_projector) { Eigen::Matrix<double, D, 1> prj; Eigen::Matrix<double, D, 1> e; for (int d = 0; d < D; d++) { @@ -74,4 +74,4 @@ void projectEdgeOnBasis(const Eigen::Matrix<double, D, D> &_basis, } } -} // namespace geometry \ No newline at end of file +} // namespace geometry diff --git a/src/geometry/point.h b/src/geometry/point.h index 894aaf6bd..5212de9a1 100644 --- a/src/geometry/point.h +++ b/src/geometry/point.h @@ -7,11 +7,9 @@ #include <stdlib.h> #include <unistd.h> -using namespace std; - namespace geometry { -template <int _K> using point = array<double, _K>; +template <int _K> using point = std::array<double, _K>; template <typename Handle, typename T> struct DerefPointIterator : public std::unary_function<Handle, T> { diff --git a/src/geometry/point.ipp b/src/geometry/point.ipp index 389be686c..ee5156f4c 100644 --- a/src/geometry/point.ipp +++ b/src/geometry/point.ipp @@ -1,15 +1,16 @@ #pragma once -using namespace geometry; +#include "point.h" +namespace geometry { // Compute an orthogonal vector. template <typename T> -inline void computeAnOrthogonalVector(array<T, 3> vector, - array<T, 3> *orthogonal) { +inline void computeAnOrthogonalVector(std::array<T, 3> vector, + std::array<T, 3> *orthogonal) { normalize(&vector); // One of (1,0,0) and (0,1,0) is independent to the vector. - array<T, 3> x = {{1, 0, 0}}; + std::array<T, 3> x = {{1, 0, 0}}; const T d0 = dot(vector, x); x[0] = 0; x[1] = 1; @@ -36,8 +37,9 @@ inline void computeAnOrthogonalVector(array<T, 3> vector, // template <typename T> -inline int computeSignOfTurn(const array<T, 2> &p, const array<T, 2> &q, - const array<T, 2> &r) { +inline int computeSignOfTurn(const std::array<T, 2> &p, + const std::array<T, 2> &q, + const std::array<T, 2> &r) { const T disc = discriminant(q - p, r - q); if (disc > 0) { return -1; @@ -48,11 +50,11 @@ inline int computeSignOfTurn(const array<T, 2> &p, const array<T, 2> &q, } template <typename T> -inline int computeApproximateSignOfTurn(const array<T, 2> &p, - const array<T, 2> &q, - const array<T, 2> &r) { - array<T, 2> u = q - p; - array<T, 2> v = r - q; +inline int computeApproximateSignOfTurn(const std::array<T, 2> &p, + const std::array<T, 2> &q, + const std::array<T, 2> &r) { + std::array<T, 2> u = q - p; + std::array<T, 2> v = r - q; normalize(&u); normalize(&v); const T disc = discriminant(u, v); @@ -64,7 +66,7 @@ inline int computeApproximateSignOfTurn(const array<T, 2> &p, return 0; } -template <typename T> inline T computePseudoAngle(const array<T, 2> &vec) { +template <typename T> inline T computePseudoAngle(const std::array<T, 2> &vec) { const T dxpdy = abs(vec[0]) + abs(vec[1]); T theta = (dxpdy == 0) ? 0 : vec[1] / dxpdy; if (vec[0] < 0) { @@ -76,7 +78,7 @@ template <typename T> inline T computePseudoAngle(const array<T, 2> &vec) { } template <size_t N, typename T> -inline T computeAngle(const array<T, N> &a, const array<T, N> &b) { +inline T computeAngle(const std::array<T, N> &a, const std::array<T, N> &b) { const T denominator = magnitude(a) * magnitude(b); // #ifdef STLIB_DEBUG // assert(denominator != 0); @@ -88,14 +90,15 @@ inline T computeAngle(const array<T, N> &a, const array<T, N> &b) { // Rotations // -template <typename T> inline void rotatePiOver2(array<T, 2> *p) { +template <typename T> inline void rotatePiOver2(std::array<T, 2> *p) { const T temp = (*p)[0]; (*p)[0] = -(*p)[1]; (*p)[1] = temp; } -template <typename T> inline void rotateMinusPiOver2(array<T, 2> *p) { +template <typename T> inline void rotateMinusPiOver2(std::array<T, 2> *p) { const T temp = (*p)[0]; (*p)[0] = (*p)[1]; (*p)[1] = -temp; } +} // namespace geometry diff --git a/src/geometry/segment.h b/src/geometry/segment.h index 06669dfb7..3e357a10a 100644 --- a/src/geometry/segment.h +++ b/src/geometry/segment.h @@ -20,7 +20,7 @@ public: segment(const point<_N> &source, const point<_N> &target) : source_(source), tangent_(), length_() { tangent_ = target - source; - length_ = magnitude<double, 2>(tangent_); + length_ = std::magnitude<double, 2>(tangent_); tangent_ /= length_; } segment(const point<_N> &source, const point<_N> &tangent, @@ -42,7 +42,7 @@ public: void make(const point<_N> &source, const point<_N> &target) { source_ = source; tangent_ = target - source; - length_ = magnitude<double, 2>(tangent_); + length_ = std::magnitude<double, 2>(tangent_); tangent_ /= length_; } @@ -80,4 +80,4 @@ inline segment<N> operator-(const segment<N> &x) { return segment<N>(x.getSource(), -x.getTangent(), x.getLength()); } -} // namespace geometry \ No newline at end of file +} // namespace geometry diff --git a/src/geometry/simplex.h b/src/geometry/simplex.h index b53969024..e658091eb 100644 --- a/src/geometry/simplex.h +++ b/src/geometry/simplex.h @@ -17,33 +17,35 @@ Eigen::Matrix3d W3((Eigen::Matrix3d() << 1.0, 0.5, 0.5, 0.0, sqrt(3.0) / 2.0, .finished()); template <int K> -void computeSolidAnglesOfSimplex(const array<point<K>, K + 1> &, - array<double, K + 1> &); +void computeSolidAnglesOfSimplex(const std::array<point<K>, K + 1> &, + std::array<double, K + 1> &); -template <int K> double simplexQuality(const array<point<K>, K + 1> &); +template <int K> double simplexQuality(const std::array<point<K>, K + 1> &); -template <int K> double simplexQuality(const array<point<K>, K> &); +template <int K> double simplexQuality(const std::array<point<K>, K> &); -template <int K> double simplexMetricResidual(const array<point<K>, K + 1> &); +template <int K> +double simplexMetricResidual(const std::array<point<K>, K + 1> &); -template <int K> double simplexMetricResidual(const array<point<K>, K> &); +template <int K> double simplexMetricResidual(const std::array<point<K>, K> &); -template <int K> double simplexVolume(const array<point<K>, K + 1> &); +template <int K> double simplexVolume(const std::array<point<K>, K + 1> &); template <int K> -double computeSimplexFaceDistance(const array<point<K>, K + 1> &, - const array<int, K> &, const point<K> &); +double computeSimplexFaceDistance(const std::array<point<K>, K + 1> &, + const std::array<int, K> &, const point<K> &); template <int K> -inline bool linearInterpolator(const array<point<K>, K + 1> &, const point<K> &, - array<double, K + 1> &, +inline bool linearInterpolator(const std::array<point<K>, K + 1> &, + const point<K> &, std::array<double, K + 1> &, const bool _allow_extrapolation = false); -template <int K> inline void compressSimplex(array<point<K>, K + 1> &, int &); +template <int K> +inline void compressSimplex(std::array<point<K>, K + 1> &, int &); template <int K> -inline void computeDeformationGradient(const array<point<K>, K> &_x_i, - const array<point<K>, K> &_X_J, +inline void computeDeformationGradient(const std::array<point<K>, K> &_x_i, + const std::array<point<K>, K> &_X_J, Eigen::Matrix<double, K, K> &_F); template <int K> @@ -53,4 +55,4 @@ inline void computeDeformationGradient(const Eigen::Matrix<double, K, K> &_x_i, } // namespace geometry -#include "simplex.ipp" \ No newline at end of file +#include "simplex.ipp" diff --git a/src/geometry/simplex.ipp b/src/geometry/simplex.ipp index ffedec602..163d0c829 100644 --- a/src/geometry/simplex.ipp +++ b/src/geometry/simplex.ipp @@ -1,7 +1,8 @@ #pragma once namespace geometry { -template <> double simplexQuality<2>(const array<point<2>, 2 + 1> &_simplex) { +template <> +double simplexQuality<2>(const std::array<point<2>, 2 + 1> &_simplex) { Eigen::Matrix<double, 2, 2> A; // Eigen::Matrix<double, 2, 2> W; Eigen::Matrix<double, 2, 2> S; @@ -22,7 +23,8 @@ template <> double simplexQuality<2>(const array<point<2>, 2 + 1> &_simplex) { return kappa_of_S; } -template <> double simplexQuality<2>(const array<point<2>, 2> &_simplex_edges) { +template <> +double simplexQuality<2>(const std::array<point<2>, 2> &_simplex_edges) { Eigen::Matrix<double, 2, 2> A; Eigen::Matrix<double, 2, 2> S; Eigen::Matrix<double, 2, 2> S_inverse; @@ -42,7 +44,8 @@ template <> double simplexQuality<2>(const array<point<2>, 2> &_simplex_edges) { return kappa_of_S; } -template <> double simplexQuality<3>(const array<point<3>, 3 + 1> &_simplex) { +template <> +double simplexQuality<3>(const std::array<point<3>, 3 + 1> &_simplex) { Eigen::Matrix<double, 3, 3> A; // Eigen::Matrix<double, 3, 3> W; Eigen::Matrix<double, 3, 3> S; @@ -71,7 +74,8 @@ template <> double simplexQuality<3>(const array<point<3>, 3 + 1> &_simplex) { return kappa_of_S; } -template <> double simplexQuality<3>(const array<point<3>, 3> &_simplex_edges) { +template <> +double simplexQuality<3>(const std::array<point<3>, 3> &_simplex_edges) { Eigen::Matrix<double, 3, 3> A; Eigen::Matrix<double, 3, 3> S; Eigen::Matrix<double, 3, 3> S_inverse; @@ -95,8 +99,8 @@ template <> double simplexQuality<3>(const array<point<3>, 3> &_simplex_edges) { } template <> -void computeSolidAnglesOfSimplex<2>(const array<point<2>, 3> &_simplex, - array<double, 2 + 1> &_angles) { +void computeSolidAnglesOfSimplex<2>(const std::array<point<2>, 3> &_simplex, + std::array<double, 2 + 1> &_angles) { point<2> side_vector_1; point<2> side_vector_2; @@ -105,13 +109,13 @@ void computeSolidAnglesOfSimplex<2>(const array<point<2>, 3> &_simplex, side_vector_1 = _simplex[(i_n + 1) % 3] - _simplex[i_n]; side_vector_2 = _simplex[(i_n + 2) % 3] - _simplex[i_n]; - _angles[i_n] = angle<double, 2>(side_vector_1, side_vector_2); + _angles[i_n] = std::angle<double, 2>(side_vector_1, side_vector_2); } } template <> -void computeSolidAnglesOfSimplex<3>(const array<point<3>, 4> &_simplex, - array<double, 3 + 1> &_angles) { +void computeSolidAnglesOfSimplex<3>(const std::array<point<3>, 4> &_simplex, + std::array<double, 3 + 1> &_angles) { point<3> side_vector_1; point<3> side_vector_2; @@ -124,17 +128,18 @@ void computeSolidAnglesOfSimplex<3>(const array<point<3>, 4> &_simplex, side_vector_2 = _simplex[(i_n + 2) % 4] - _simplex[i_n]; side_vector_3 = _simplex[(i_n + 3) % 4] - _simplex[i_n]; - volume = tripleProduct<double>(side_vector_1, side_vector_2, side_vector_3); + volume = + std::tripleProduct<double>(side_vector_1, side_vector_2, side_vector_3); - div = magnitude<double, 3>(side_vector_1) * - magnitude<double, 3>(side_vector_2) * - magnitude<double, 3>(side_vector_3) + - dot<double, 3>(side_vector_1, side_vector_2) * - magnitude<double, 3>(side_vector_3) + - dot<double, 3>(side_vector_3, side_vector_2) * - magnitude<double, 3>(side_vector_1) + - dot<double, 3>(side_vector_1, side_vector_3) * - magnitude<double, 3>(side_vector_2); + div = std::magnitude<double, 3>(side_vector_1) * + std::magnitude<double, 3>(side_vector_2) * + std::magnitude<double, 3>(side_vector_3) + + std::dot<double, 3>(side_vector_1, side_vector_2) * + std::magnitude<double, 3>(side_vector_3) + + std::dot<double, 3>(side_vector_3, side_vector_2) * + std::magnitude<double, 3>(side_vector_1) + + std::dot<double, 3>(side_vector_1, side_vector_3) * + std::magnitude<double, 3>(side_vector_2); double arctan = atan(volume / div); // this is not the correct way of converting negative solid angles to @@ -146,18 +151,19 @@ void computeSolidAnglesOfSimplex<3>(const array<point<3>, 4> &_simplex, } template <int K> -double simplexMetricResidual(const array<point<K>, K + 1> &_simplex) { +double simplexMetricResidual(const std::array<point<K>, K + 1> &_simplex) { double ks = simplexQuality<K>(_simplex); return (1.0 - ks) * (1.0 / (ks)-1.0); } template <int K> -double simplexMetricResidual(const array<point<K>, K> &_simplex_edges) { +double simplexMetricResidual(const std::array<point<K>, K> &_simplex_edges) { double ks = simplexQuality<K>(_simplex_edges); return (1.0 - ks) * (1.0 / (ks)-1.0); } -template <> double simplexVolume<2>(const array<point<2>, 2 + 1> &_triangle) { +template <> +double simplexVolume<2>(const std::array<point<2>, 2 + 1> &_triangle) { return (_triangle[0][0] * (_triangle[1][1] - _triangle[2][1]) + _triangle[1][0] * (_triangle[2][1] - _triangle[0][1]) + _triangle[2][0] * (_triangle[0][1] - _triangle[1][1])) / @@ -165,7 +171,7 @@ template <> double simplexVolume<2>(const array<point<2>, 2 + 1> &_triangle) { } template <> -double simplexVolume<3>(const array<point<3>, 3 + 1> &_tetrahedron) { +double simplexVolume<3>(const std::array<point<3>, 3 + 1> &_tetrahedron) { const point<3> &a = _tetrahedron[1]; const point<3> &b = _tetrahedron[2]; const point<3> &c = _tetrahedron[3]; @@ -181,35 +187,37 @@ double simplexVolume<3>(const array<point<3>, 3 + 1> &_tetrahedron) { } template <> -double computeSimplexFaceDistance<2>(const array<point<2>, 2 + 1> &_simplex, - const array<int, 2> &_face, - const point<2> &_pt) { +double +computeSimplexFaceDistance<2>(const std::array<point<2>, 2 + 1> &_simplex, + const std::array<int, 2> &_face, + const point<2> &_pt) { point<2> tangent = _simplex[_face[1]] - _simplex[_face[0]]; point<2> normal = {tangent[1], -tangent[0]}; - double distance = abs(dot<double>(normal, _pt - _simplex[_face[0]])); + double distance = abs(std::dot<double>(normal, _pt - _simplex[_face[0]])); return distance; } template <> -double computeSimplexFaceDistance<3>(const array<point<3>, 3 + 1> &_simplex, - const array<int, 3> &_face, - const point<3> &_pt) { - point<3> normal = cross<double>(_simplex[_face[1]] - _simplex[_face[0]], - _simplex[_face[2]] - _simplex[_face[0]]); +double +computeSimplexFaceDistance<3>(const std::array<point<3>, 3 + 1> &_simplex, + const std::array<int, 3> &_face, + const point<3> &_pt) { + point<3> normal = std::cross<double>(_simplex[_face[1]] - _simplex[_face[0]], + _simplex[_face[2]] - _simplex[_face[0]]); - normalize<double, 3>(&normal); + std::normalize<double, 3>(&normal); - double distance = abs(dot<double>(normal, _pt - _simplex[_face[0]])); + double distance = abs(std::dot<double>(normal, _pt - _simplex[_face[0]])); return distance; } template <> -inline bool linearInterpolator<3>(const array<point<3>, 3 + 1> &_simplex, +inline bool linearInterpolator<3>(const std::array<point<3>, 3 + 1> &_simplex, const point<3> &_point, - array<double, 3 + 1> &_values, + std::array<double, 3 + 1> &_values, const bool _allow_extrapolation) { bool returnVal; _values.fill(0.0); @@ -226,7 +234,7 @@ inline bool linearInterpolator<3>(const array<point<3>, 3 + 1> &_simplex, if (!if_vertex) { const double volume = simplexVolume<3>(_simplex); - array<point<3>, 3 + 1> subvertices; + std::array<point<3>, 3 + 1> subvertices; subvertices[0] = _point; subvertices[1] = _simplex[1]; subvertices[2] = _simplex[2]; @@ -253,10 +261,10 @@ inline bool linearInterpolator<3>(const array<point<3>, 3 + 1> &_simplex, returnVal = true; - // if(any_of( + // if(std::any_of( // begin(_values), end(_values), [](double i){ return i < -1.0e-6; })) - if (any_of(begin(_values), end(_values), - [](double i) { return i < -1.0e-4; })) { + if (std::any_of(begin(_values), end(_values), + [](double i) { return i < -1.0e-4; })) { if (!_allow_extrapolation) _values.fill(0.0); @@ -267,8 +275,8 @@ inline bool linearInterpolator<3>(const array<point<3>, 3 + 1> &_simplex, } template <> -inline void computeDeformationGradient<2>(const array<point<2>, 2> &_x_i, - const array<point<2>, 2> &_X_J, +inline void computeDeformationGradient<2>(const std::array<point<2>, 2> &_x_i, + const std::array<point<2>, 2> &_X_J, Eigen::Matrix<double, 2, 2> &_F) { // instead of copying over to eigen, // and then computing, @@ -285,8 +293,8 @@ inline void computeDeformationGradient<2>(const array<point<2>, 2> &_x_i, } template <> -inline void computeDeformationGradient<3>(const array<point<3>, 3> &_x_i, - const array<point<3>, 3> &_X_J, +inline void computeDeformationGradient<3>(const std::array<point<3>, 3> &_x_i, + const std::array<point<3>, 3> &_X_J, Eigen::Matrix<double, 3, 3> &_F) { // instead of copying over to eigen, // and then computing, @@ -345,7 +353,7 @@ inline void computeDeformationGradient(const Eigen::Matrix<double, K, K> &_x_i, } template <> -inline void compressSimplex<3>(array<point<3>, 3 + 1> &_simplex, int &_d) { +inline void compressSimplex<3>(std::array<point<3>, 3 + 1> &_simplex, int &_d) { double d2FaceMin = 9999.9; double d2Face; _d = 0; @@ -353,12 +361,12 @@ inline void compressSimplex<3>(array<point<3>, 3 + 1> &_simplex, int &_d) { point<3> newPt, normal; for (int d = 0; d < 3 + 1; d++) { - normal = cross(_simplex[(d + 2) % 4] - _simplex[(d + 1) % 4], - _simplex[(d + 3) % 4] - _simplex[(d + 1) % 4]); + normal = std::cross(_simplex[(d + 2) % 4] - _simplex[(d + 1) % 4], + _simplex[(d + 3) % 4] - _simplex[(d + 1) % 4]); - normalize<double, 3>(&normal); + std::normalize<double, 3>(&normal); - d2Face = dot(_simplex[d] - _simplex[(d + 1) % 4], normal); + d2Face = std::dot(_simplex[d] - _simplex[(d + 1) % 4], normal); if (d2FaceMin > abs(d2Face)) { d2FaceMin = abs(d2Face); @@ -371,4 +379,4 @@ inline void compressSimplex<3>(array<point<3>, 3 + 1> &_simplex, int &_d) { _simplex[_d] = newPt; } -} // namespace geometry \ No newline at end of file +} // namespace geometry diff --git a/src/geometry/squareMat.h b/src/geometry/squareMat.h index 1c19a3e1c..8be6b1ccd 100644 --- a/src/geometry/squareMat.h +++ b/src/geometry/squareMat.h @@ -7,12 +7,11 @@ #include <stdlib.h> #include <unistd.h> -using namespace std; - namespace geometry { // ! for small matrices, no need of eigen. squareMat[i] gives ith row. -template <typename T = double, int N> using squareMat = array<array<T, N>, N>; +template <typename T = double, int N> +using squareMat = std::array<std::array<T, N>, N>; // ! get minor(i,j) of the matrix template <typename T, int N> diff --git a/src/input/userinput.h b/src/input/userinput.h index 8364d9537..178b0632c 100644 --- a/src/input/userinput.h +++ b/src/input/userinput.h @@ -5,27 +5,26 @@ #include <sstream> #include <string> #include <vector> -using namespace std; class userinput { - string ParametersFileName; + std::string ParametersFileName; public: //mesh Parameters int n_coarsening_levels_i; double coarsening_factor_i; - array<double, 3> atomistic_domain_i; + std::array<double, 3> atomistic_domain_i; double initial_level_i; double x_char_i; int N_zones_i; int constrained_direction_i; - array<bool, 3> periodic_flags_i; + std::array<bool, 3> periodic_flags_i; bool apply_fixed_flag_i; - array<double, 3> fixed_box_upper_i; - array<double, 3> fixed_box_lower_i; + std::array<double, 3> fixed_box_upper_i; + std::array<double, 3> fixed_box_lower_i; - vector<array<double, 3>> display_neighbourhoods_sampling_atoms_i; + std::vector<std::array<double, 3>> display_neighbourhoods_sampling_atoms_i; bool read_restart_i; bool intialize_force_applicator_i; @@ -42,12 +41,12 @@ public: int restart_files_freq_i; int midFIRE_solution_files_freq_i; - string potential_file_location_i; - string potentialMaterial_name_i; + std::string potential_file_location_i; + std::string potentialMaterial_name_i; - string restart_file_name_i; - string neighbour_update_style_i; - string mesh_file_i; + std::string restart_file_name_i; + std::string neighbour_update_style_i; + std::string mesh_file_i; double node_effective_radius_i; double side_effective_radius_i; bool enable_second_order_i; @@ -74,7 +73,7 @@ public: double strain_increment_time_step_i; std::array<double, 3> indenter_center_i; double initial_offset_i; - array<double, 9> external_displacement_gradient_i; + std::array<double, 9> external_displacement_gradient_i; double FIRE_time_step_i; double FIRE_initial_time_step_i; @@ -113,8 +112,8 @@ public: int max_iter_i, max_feval_i; void readParametersXMLFile(); - bool string2bool(string s); - std::array<double, 3> string2Doublearray(string s); + bool string2bool(std::string s); + std::array<double, 3> string2Doublearray(std::string s); // trim from start void trimWhitespaceFromStartOfString(std::string *s) { s->erase(s->begin(), diff --git a/src/lattice/inputLatticeGenerators.h b/src/lattice/inputLatticeGenerators.h index 0f00e797f..80740cc3b 100644 --- a/src/lattice/inputLatticeGenerators.h +++ b/src/lattice/inputLatticeGenerators.h @@ -1,5 +1,3 @@ - - #include "geometry.h" #include "utilities.h" @@ -11,7 +9,7 @@ * or write your own and include here. The ouput of these lattice generators * will be used for creating the mesh */ -typedef typename vector<point<DIM>>::iterator pointIt; +typedef typename std::vector<point<DIM>>::iterator pointIt; typedef DerefPointIterator<pointIt, point<DIM>> pointLocator; // needs reserve to work diff --git a/src/lattice/lattice.h b/src/lattice/lattice.h index 99d5a2766..d4e4cb90a 100644 --- a/src/lattice/lattice.h +++ b/src/lattice/lattice.h @@ -17,25 +17,23 @@ #include "uniquePointContainer.h" #include "utilities.h" #include "variables.h" -using namespace std; -using namespace geometry; namespace lattice { template <class Point, int DIM> class Lattice { public: typedef Eigen::Matrix<double, DIM, DIM> Matrix; - typedef typename vector<Point>::iterator latticeIt; + typedef typename std::vector<Point>::iterator latticeIt; typedef DerefPointIterator<latticeIt, Point> latticeLocator; int n_sublattice; - vector<LatticeStructure> lattice_structures; - vector<Matrix> basis; - vector<Matrix> orientations; - vector<Point> lattice_sites; - vector<Lattice> sub_lattices; - vector<int> lattice_sites_material_idx; - - Lattice(int n_sub, vector<material<DIM> *> _materials) { + std::vector<LatticeStructure> lattice_structures; + std::vector<Matrix> basis; + std::vector<Matrix> orientations; + std::vector<Point> lattice_sites; + std::vector<Lattice> sub_lattices; + std::vector<int> lattice_sites_material_idx; + + Lattice(int n_sub, std::vector<material<DIM> *> _materials) { this->n_sublattice = n_sub; this->lattice_structures.resize(this->n_sublattice); this->basis.resize(this->n_sublattice); @@ -51,8 +49,8 @@ public: } } - void AssignBasisVectors(vector<material<DIM> *> _materials) - // vector<vector<vector<double>>> BasisVectorsVector) + void AssignBasisVectors(std::vector<material<DIM> *> _materials) + // std::vector<std::vector<std::vector<double>>> BasisVectorsVector) { for (int i_sublattice = 0; i_sublattice < this->n_sublattice; i_sublattice++) { @@ -66,13 +64,13 @@ public: } void WriteLatticeFile() { - ofstream f_lattice; + std::ofstream f_lattice; f_lattice.open("./InitialLattice.dat"); for (int n = 0; n < this->lattice_sites.size(); n++) { for (int d = 0; d < DIM - 1; d++) { f_lattice << this->lattice_sites[n][d] << " "; } - f_lattice << this->lattice_sites[n][DIM - 1] << endl; + f_lattice << this->lattice_sites[n][DIM - 1] << std::endl; } f_lattice.close(); } @@ -83,8 +81,8 @@ public: }; template <int DIM> -void convertLatticeLocations(vector<CGAL_POINT> &_locations, - const vector<point<DIM>> &_atoms) { +void convertLatticeLocations(std::vector<CGAL_POINT> &_locations, + const std::vector<point<DIM>> &_atoms) { _locations.reserve(_atoms.size()); for (int ip = 0; ip < _atoms.size(); ip++) { @@ -96,7 +94,7 @@ void convertLatticeLocations(vector<CGAL_POINT> &_locations, } } template <class Point, int DIM> -void FindClosestLatticeSite(const vector<Point> &_lattice_sites, +void FindClosestLatticeSite(const std::vector<Point> &_lattice_sites, const Point &_inputp, Point &outputp, int &OutputIDX) { double r; @@ -116,9 +114,9 @@ void FindClosestLatticeSite(const vector<Point> &_lattice_sites, } template <class Point, int DIM, class Boundary_d> -void GetLatticeSitesonStraightBoundary(Lattice<Point, DIM> &Lattice_OBJ, - vector<Boundary_d> &Boundaries, - vector<vector<Point>> &BoundarySites) { +void GetLatticeSitesonStraightBoundary( + Lattice<Point, DIM> &Lattice_OBJ, std::vector<Boundary_d> &Boundaries, + std::vector<std::vector<Point>> &BoundarySites) { for (int boundary_ctr = 0; boundary_ctr < Boundaries.size(); boundary_ctr++) { for (Point &p : Lattice_OBJ.lattice_sites) { if (CheckIfPointCloseToStraightBoundary<Point, DIM>( @@ -156,11 +154,11 @@ void GetCenterLatticeSite(Lattice<Point, DIM> &Lattice_OBJ, Box domain, template <class Box, class Point, int DIM> void AssignCoarseningBoundingBoxes(Lattice<Point, DIM> &Lattice_OBJ, - vector<int> NoofCoarseBoxes, Box domain, - vector<Box> &CoarseningBoxes, - vector<int> &AmountOfCoarsening, + std::vector<int> NoofCoarseBoxes, Box domain, + std::vector<Box> &CoarseningBoxes, + std::vector<int> &AmountOfCoarsening, Point Center) { - vector<vector<double>> CoarseningCoordinates; + std::vector<std::vector<double>> CoarseningCoordinates; for (int i_box = 0; i_box < NoofCoarseBoxes[0]; i_box++) { double hx = (domain.xmax() - domain.xmin()) / double(NoofCoarseBoxes[0]); @@ -234,7 +232,7 @@ bool CheckIfLatticeSiteIsInBox(const Point &p, Box box) { template <typename RepAtom, typename Box_d, typename Point_d, int DIM> void AssignAllLatticeSitesInBoxAsRepAtoms( const Lattice<Point_d, DIM> &_latiice_obj, Box_d _domain, - vector<RepAtom> &_repatoms) { + std::vector<RepAtom> &_repatoms) { int p_ctr = 0; for (const Point_d &p : _latiice_obj.lattice_sites) { @@ -251,10 +249,10 @@ template <typename RepAtom, typename Boundary_d, typename Box_d, typename Point_d, int DIM> void AssignCoarsenedLatticeSitesAsRepAtoms( const Lattice<Point_d, DIM> &_lattice_obj, Box_d _domain, int _n_repatoms, - vector<RepAtom> &_repatoms, - // vector<Point_d> &RepAtomPositions, vector<int> &MaterialsIdx, - const vector<vector<Point_d>> &_boundary_sites, - const vector<Boundary_d> &_boundaries) { + std::vector<RepAtom> &_repatoms, + // std::vector<Point_d> &RepAtomPositions, std::vector<int> &MaterialsIdx, + const std::vector<std::vector<Point_d>> &_boundary_sites, + const std::vector<Boundary_d> &_boundaries) { bool if_uniform_point_close_to_boundary = false; int repatom_idx; RepAtom repatom_to_be_added; @@ -307,9 +305,9 @@ void AssignCoarsenedLatticeSitesAsRepAtoms( } } template <int DIM> -void GetNumberOfLatticeSites(const vector<vector<double>> &_bravais_vectors, - const double &_rcut, - vector<int> &noof_lattice_sites) { +void GetNumberOfLatticeSites( + const std::vector<std::vector<double>> &_bravais_vectors, + const double &_rcut, std::vector<int> &noof_lattice_sites) { double min_length = _rcut; for (int d = 0; d < DIM; d++) { double vec_length = Utilities::MAGNITUDE(_bravais_vectors[d]); @@ -322,10 +320,11 @@ void GetNumberOfLatticeSites(const vector<vector<double>> &_bravais_vectors, } template <int DIM> -void GetNumberOfLatticeSites(const vector<vector<double>> &_bravais_vectors, - vector<pair<int, int>> &noof_lattice_sites, - const std::array<point<DIM>, DIM + 1> &_simplex) { - vector<point<DIM>> edge_vectors(DIM); +void GetNumberOfLatticeSites( + const std::vector<std::vector<double>> &_bravais_vectors, + std::vector<std::pair<int, int>> &noof_lattice_sites, + const std::array<point<DIM>, DIM + 1> &_simplex) { + std::vector<point<DIM>> edge_vectors(DIM); Eigen::Matrix<int, DIM, DIM> lattice_sites_vertices; Eigen::VectorXi lattice_sites_upper_vertex(DIM); Eigen::VectorXi lattice_sites_lower_vertex(DIM); @@ -342,9 +341,9 @@ void GetNumberOfLatticeSites(const vector<vector<double>> &_bravais_vectors, lattice_sites_vertices); if (lattice_sites_vertices.determinant() == 0.0) { - cout << "Transformation matrix from edges to bravais vectors is " - "singular! Exiting..." - << endl; + std::cout << "Transformation matrix from edges to bravais vectors is " + "singular! Exiting..." + << std::endl; exit(0); } @@ -353,8 +352,9 @@ void GetNumberOfLatticeSites(const vector<vector<double>> &_bravais_vectors, lattice_sites_lower_vertex = lattice_sites_vertices.rowwise().minCoeff(); for (int d = 0; d < DIM; d++) { - noof_lattice_sites[d] = make_pair(round(lattice_sites_lower_vertex[d]), - round(lattice_sites_upper_vertex[d])); + noof_lattice_sites[d] = + std::make_pair(round(lattice_sites_lower_vertex[d]), + round(lattice_sites_upper_vertex[d])); } } } @@ -389,15 +389,15 @@ void generateAndAddNeighbourhood( const point<DIM> &_closest_lattice_site, const point<DIM> &_offset, const double &_distance_from_sampling_atom, const double &_radius, const Eigen::Matrix<double, DIM, DIM> &_vectors, - const array<point<DIM>, DIM + 1> &_simplex, + const std::array<point<DIM>, DIM + 1> &_simplex, #ifdef FINITE_TEMPERATURE - const array<array<double, NIDOF>, DIM + 1> &_thermal_simplex, + const std::array<std::array<double, NIDOF>, DIM + 1> &_thermal_simplex, #endif - const array<size_t, DIM + 1> &_ind_simplex, const int &_rank, + const std::array<size_t, DIM + 1> &_ind_simplex, const int &_rank, const bool &_interproc_neighbour_flag, const bool &_periodic_neighbour_flag, const bool &_doing_cauchy_born_sampling_atom, uniqueLatticeSiteList<point<DIM>, DIM> &_unique_neighbourhood_container, - vector<latticeSite<DIM, NIDOF>> &_neighbour_lattice_sites, + std::vector<latticeSite<DIM, NIDOF>> &_neighbour_lattice_sites, bool print = false); template <> @@ -405,24 +405,24 @@ void generateAndAddNeighbourhood<3, 2>( const point<3> &_closest_lattice_site, const point<DIM> &_offset, const double &_distance_from_sampling_atom, const double &_radius, const Eigen::Matrix<double, 3, 3> &_vectors, - const array<point<3>, 3 + 1> &_simplex, + const std::array<point<3>, 3 + 1> &_simplex, #ifdef FINITE_TEMPERATURE - const array<array<double, 2>, 3 + 1> &_thermal_simplex, + const std::array<std::array<double, 2>, 3 + 1> &_thermal_simplex, #endif - const array<size_t, 3 + 1> &_ind_simplex, const int &_rank, + const std::array<size_t, 3 + 1> &_ind_simplex, const int &_rank, const bool &_interproc_neighbour_flag, const bool &_periodic_neighbour_flag, const bool &_doing_cauchy_born_sampling_atom, uniqueLatticeSiteList<point<3>, 3> &_unique_neighbourhood_container, - vector<latticeSite<3, 2>> &_neighbour_lattice_sites, bool print) { + std::vector<latticeSite<3, 2>> &_neighbour_lattice_sites, bool print) { - array<double, 3> u, v, w; + std::array<double, 3> u, v, w; double extended_radius = _radius + _distance_from_sampling_atom; Utilities::GET_ARRAYS_3(_vectors, u, v, w); point<3> lattice_site; - array<int, 3> bounds_cells_in_directions; + std::array<int, 3> bounds_cells_in_directions; bounds_cells_in_directions[0] = int((extended_radius) / magnitude(u)); @@ -434,7 +434,7 @@ void generateAndAddNeighbourhood<3, 2>( bool inside_radius; bool added; - array<double, 3 + 1> Nj; + std::array<double, 3 + 1> Nj; double distance_squared; // bounds_cells_in_directions[0] = 2; @@ -481,22 +481,22 @@ void generateAndAddNeighbourhood<3, 2>( if (added) { if (print) { { - cout << "simplex is " << endl; + std::cout << "simplex is " << std::endl; for (int i = 0; i < 4; i++) - cout << _simplex[i] << endl; + std::cout << _simplex[i] << std::endl; - cout << "closest lattice site " << _closest_lattice_site - << endl; + std::cout << "closest lattice site " + << _closest_lattice_site << std::endl; } - cout << "volume is :" << abs(simplexVolume<3>(_simplex)) - << endl; - cout << "adding generated " << i << " " << j << " " << k - << " : " << lattice_site << endl; - cout << "basis are " << endl; - cout << u << endl; - cout << v << endl; - cout << w << endl; + std::cout << "volume is :" << abs(simplexVolume<3>(_simplex)) + << std::endl; + std::cout << "adding generated " << i << " " << j << " " << k + << " : " << lattice_site << std::endl; + std::cout << "basis are " << std::endl; + std::cout << u << std::endl; + std::cout << v << std::endl; + std::cout << w << std::endl; } _neighbour_lattice_sites.emplace_back(lattice_site, _offset, Nj, #ifdef FINITE_TEMPERATURE @@ -532,45 +532,47 @@ void generateAndAddNeighbourhood<3, 2>( } template <int DIM, typename Point> -void CreateAllLatticeSitesWithinSimplex(const array<Point, DIM + 1> &, - const vector<vector<double>> &, - const double &, vector<Point> &); +void CreateAllLatticeSitesWithinSimplex( + const std::array<Point, DIM + 1> &, + const std::vector<std::vector<double>> &, const double &, + std::vector<Point> &); template <int DIM, typename Point> -void CreateLatticeSidesWithinSimplexRadius(const array<Point, DIM + 1> &, - const vector<vector<double>> &, - const double &, vector<Point> &); +void CreateLatticeSidesWithinSimplexRadius( + const std::array<Point, DIM + 1> &, + const std::vector<std::vector<double>> &, const double &, + std::vector<Point> &); template <int DIM, typename Point> void CreateLatticeSidesWithinRadius(const Point &, - const vector<vector<double>> &, - const double &, vector<Point> &); + const std::vector<std::vector<double>> &, + const double &, std::vector<Point> &); template <typename Point_d, typename Bound_d, int DIM> void CreateLatticeSitesInBounds(Bound_d &, const Bound_d &, - const vector<Point_d> &, - const vector<vector<double>> &, - vector<point<DIM>> &, vector<int> &); + const std::vector<Point_d> &, + const std::vector<std::vector<double>> &, + std::vector<point<DIM>> &, std::vector<int> &); template <> void CreateLatticeSitesInBounds<point<2>, Box<point<2>, 2>, 2>( Box<point<2>, 2> &_box, const Box<point<2>, 2> &_lower_box, - const vector<point<2>> &_seed_points, - const vector<vector<double>> &_vectors, vector<point<2>> &_latticeSites, - vector<int> &_materialIDs) { + const std::vector<point<2>> &_seed_points, + const std::vector<std::vector<double>> &_vectors, + std::vector<point<2>> &_latticeSites, std::vector<int> &_materialIDs) { int lattice_site_idx; // double r_cut = // 0.5*_box.upper_.distance(_lower_box.upper_); double r_cut = distance(_box.upper_, _box.lower_); - vector<int> number_of_lattice_sites; + std::vector<int> number_of_lattice_sites; GetNumberOfLatticeSites<2>(_vectors, r_cut, number_of_lattice_sites); point<2> px = {{_vectors[0][0], _vectors[0][1]}}; point<2> py = {{_vectors[1][0], _vectors[1][1]}}; - vector<point<2>> box_sites; + std::vector<point<2>> box_sites; point<2> new_lower = (_box.lower_ + _box.upper_) * 0.5; point<2> new_upper = (_box.lower_ + _box.upper_) * 0.5; @@ -621,15 +623,15 @@ void CreateLatticeSitesInBounds<point<2>, Box<point<2>, 2>, 2>( template <> void CreateLatticeSitesInBounds<point<3>, Box<point<3>, 3>, 3>( Box<point<3>, 3> &_box, const Box<point<3>, 3> &_lower_box, - const vector<point<3>> &_seed_points, - const vector<vector<double>> &_vectors, vector<point<3>> &_latticeSites, - vector<int> &_materialIDs) { + const std::vector<point<3>> &_seed_points, + const std::vector<std::vector<double>> &_vectors, + std::vector<point<3>> &_latticeSites, std::vector<int> &_materialIDs) { // double r_cut = // 0.5*_box.upper_.distance(_lower_box.upper_); double r_cut = distance(_box.upper_, _box.lower_); - vector<int> number_of_lattice_sites; + std::vector<int> number_of_lattice_sites; GetNumberOfLatticeSites<3>(_vectors, r_cut, number_of_lattice_sites); @@ -679,17 +681,18 @@ void CreateLatticeSitesInBounds<point<3>, Box<point<3>, 3>, 3>( uniqueContainer.clear(); - bindBox< - Box<point<DIM>, DIM>, typename vector<point<DIM>>::iterator, - DerefPointIterator<typename vector<point<DIM>>::iterator, point<DIM>>>( - _latticeSites.begin(), _latticeSites.end(), _box); + bindBox<Box<point<DIM>, DIM>, typename std::vector<point<DIM>>::iterator, + DerefPointIterator<typename std::vector<point<DIM>>::iterator, + point<DIM>>>(_latticeSites.begin(), + _latticeSites.end(), _box); } template <> void CreateLatticeSidesWithinRadius<2, point<2>>( - const point<2> &_center, const vector<vector<double>> &_bravais_vectors, - const double &_rcut, vector<point<2>> &_latticesites) { - vector<int> noof_lattice_sites; + const point<2> &_center, + const std::vector<std::vector<double>> &_bravais_vectors, + const double &_rcut, std::vector<point<2>> &_latticesites) { + std::vector<int> noof_lattice_sites; _latticesites.resize(0); GetNumberOfLatticeSites<2>(_bravais_vectors, _rcut, noof_lattice_sites); @@ -713,14 +716,14 @@ void CreateLatticeSidesWithinRadius<2, point<2>>( template <> void CreateAllLatticeSitesWithinSimplex<2, point<2>>( - const array<point<2>, 2 + 1> &_simplex, - const vector<vector<double>> &_bravais_vectors, const double &_rcut, - vector<point<2>> &_latticesites) { + const std::array<point<2>, 2 + 1> &_simplex, + const std::vector<std::vector<double>> &_bravais_vectors, + const double &_rcut, std::vector<point<2>> &_latticesites) { point<2> Center; - vector<int> aligned_vectors_id; - vector<int> noof_lattice_sites; + std::vector<int> aligned_vectors_id; + std::vector<int> noof_lattice_sites; double direction; bool added; @@ -758,14 +761,14 @@ void CreateAllLatticeSitesWithinSimplex<2, point<2>>( template <> void CreateAllLatticeSitesWithinSimplex<3, point<3>>( - const array<point<3>, 3 + 1> &_simplex, - const vector<vector<double>> &_bravais_vectors, const double &_rcut, - vector<point<3>> &_latticesites) { + const std::array<point<3>, 3 + 1> &_simplex, + const std::vector<std::vector<double>> &_bravais_vectors, + const double &_rcut, std::vector<point<3>> &_latticesites) { point<3> Center; - vector<int> aligned_vectors_id; - vector<int> noof_lattice_sites; + std::vector<int> aligned_vectors_id; + std::vector<int> noof_lattice_sites; double direction; bool added; @@ -804,11 +807,11 @@ void CreateAllLatticeSitesWithinSimplex<3, point<3>>( template <> void CreateLatticeSidesWithinSimplexRadius<2, point<2>>( - const array<point<2>, 2 + 1> &_simplex, - const vector<vector<double>> &_bravais_vectors, const double &_rcut, - vector<point<2>> &_latticesites) { + const std::array<point<2>, 2 + 1> &_simplex, + const std::vector<std::vector<double>> &_bravais_vectors, + const double &_rcut, std::vector<point<2>> &_latticesites) { point<2> Center; - vector<pair<int, int>> noof_lattice_sites; + std::vector<std::pair<int, int>> noof_lattice_sites; GetNumberOfLatticeSites<2>(_bravais_vectors, noof_lattice_sites, _simplex); @@ -816,10 +819,10 @@ void CreateLatticeSidesWithinSimplexRadius<2, point<2>>( geom::SimplexDistance<2, 2, double> simplexDistance(_simplex); - for (int i = min(0, noof_lattice_sites[0].first); - i < max(0, noof_lattice_sites[0].second) + 1; i++) { - for (int j = min(0, noof_lattice_sites[1].first); - j < max(0, noof_lattice_sites[1].second) + 1; j++) { + for (int i = std::min(0, noof_lattice_sites[0].first); + i < std::max(0, noof_lattice_sites[0].second) + 1; i++) { + for (int j = std::min(0, noof_lattice_sites[1].first); + j < std::max(0, noof_lattice_sites[1].second) + 1; j++) { point<2> lattice_site; for (int d = 0; d < 2; d++) { lattice_site[d] = Center[d] + double(i) * _bravais_vectors[0][d] + @@ -841,23 +844,23 @@ void CreateLatticeSidesWithinSimplexRadius<2, point<2>>( } template <> void CreateLatticeSidesWithinSimplexRadius<3, point<3>>( - const array<point<3>, 3 + 1> &_simplex, - const vector<vector<double>> &_bravais_vectors, const double &_rcut, - vector<point<3>> &_latticesites) { + const std::array<point<3>, 3 + 1> &_simplex, + const std::vector<std::vector<double>> &_bravais_vectors, + const double &_rcut, std::vector<point<3>> &_latticesites) { point<3> Center; - vector<pair<int, int>> noof_lattice_sites; + std::vector<std::pair<int, int>> noof_lattice_sites; GetNumberOfLatticeSites<3>(_bravais_vectors, noof_lattice_sites, _simplex); Center = _simplex[0]; geom::SimplexDistance<3, 3, double> simplexDistance(_simplex); - for (int i = min(0, noof_lattice_sites[0].first); - i < max(0, noof_lattice_sites[0].second) + 1; i++) { - for (int j = min(0, noof_lattice_sites[1].first); - j < max(0, noof_lattice_sites[1].second) + 1; j++) { - for (int k = min(0, noof_lattice_sites[2].first); - k < max(0, noof_lattice_sites[2].second) + 1; k++) { + for (int i = std::min(0, noof_lattice_sites[0].first); + i < std::max(0, noof_lattice_sites[0].second) + 1; i++) { + for (int j = std::min(0, noof_lattice_sites[1].first); + j < std::max(0, noof_lattice_sites[1].second) + 1; j++) { + for (int k = std::min(0, noof_lattice_sites[2].first); + k < std::max(0, noof_lattice_sites[2].second) + 1; k++) { point<3> lattice_site; for (int d = 0; d < 3; d++) { lattice_site[d] = Center[d] + double(i) * _bravais_vectors[0][d] + @@ -884,4 +887,4 @@ void CreateLatticeSidesWithinSimplexRadius<3, point<3>>( } } } -} // namespace lattice \ No newline at end of file +} // namespace lattice diff --git a/src/lattice/latticeGenerators/NanoIndentation/NanoIndentation.h b/src/lattice/latticeGenerators/NanoIndentation/NanoIndentation.h index 201b9f2af..96c0ca5d0 100644 --- a/src/lattice/latticeGenerators/NanoIndentation/NanoIndentation.h +++ b/src/lattice/latticeGenerators/NanoIndentation/NanoIndentation.h @@ -1,12 +1,18 @@ +#pragma once +#include <array> +#include <vector> + // generate the lattice points for initializing a lomer dipole // sample input file. Builds lattice, displaces lattice points according to // linear elastic dipole fields, and trims the lattice points + template <int DIM> -void GenerateLattice(vector<point<DIM>> &_lattice_points, - vector<int> &_materialIDs, Box<point<DIM>, DIM> &_bounds, - string &_name, Box<point<DIM>, DIM> &_atomistic_domain, +void GenerateLattice(std::vector<point<DIM>> &_lattice_points, + std::vector<int> &_materialIDs, + Box<point<DIM>, DIM> &_bounds, std::string &_name, + Box<point<DIM>, DIM> &_atomistic_domain, int &_saveLatticeVectors, - const array<array<double, DIM>, DIM> &_basis) { + const std::array<std::array<double, DIM>, DIM> &_basis) { //-----------<Default values>------------// int n_coarsening_levels = 2; @@ -23,10 +29,10 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, point<DIM> offset = {{0.0, 0.0, 0.0}}; bool apply_fixed_box = true; - vector<double> coarsening_factors; + std::vector<double> coarsening_factors; int initial_level = 1; - vector<double> domain_expansion_factors; + std::vector<double> domain_expansion_factors; domain_expansion_factors.resize(n_coarsening_levels); coarsening_factors.resize(n_coarsening_levels); @@ -43,7 +49,7 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, burgerV = 0.0; nu = 0.45; //-----------</Default values>------------// - vector<string> tokens; + std::vector<std::string> tokens; _saveLatticeVectors = 0; // use the below interface functions to enable an input file @@ -59,39 +65,41 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, pugi::xml_node Fields = parent_node.child("Fields"); for (pugi::xml_node Field = Fields.first_child(); Field; Field = Field.next_sibling("Field")) { - if (string(Field.attribute("Name").value()) == "n_coarsening_levels") - n_coarsening_levels = stoi(Field.child_value()); + if (std::string(Field.attribute("Name").value()) == "n_coarsening_levels") + n_coarsening_levels = std::stoi(Field.child_value()); - if (string(Field.attribute("Name").value()) == "x_char") - x_char = stod(Field.child_value()); + if (std::string(Field.attribute("Name").value()) == "x_char") + x_char = std::stod(Field.child_value()); - if (string(Field.attribute("Name").value()) == "atomistic_domain") + if (std::string(Field.attribute("Name").value()) == "atomistic_domain") atomistic_domain = FileUtilities::string2Doublearray(Field.child_value()); - if (string(Field.attribute("Name").value()) == "domain_upper") + if (std::string(Field.attribute("Name").value()) == "domain_upper") domain_upper = FileUtilities::string2Doublearray(Field.child_value()); - if (string(Field.attribute("Name").value()) == "domain_lower") + if (std::string(Field.attribute("Name").value()) == "domain_lower") domain_lower = FileUtilities::string2Doublearray(Field.child_value()); - if (string(Field.attribute("Name").value()) == "save_lattice_vectors_flag") + if (std::string(Field.attribute("Name").value()) == + "save_lattice_vectors_flag") _saveLatticeVectors = int(FileUtilities::string2bool(Field.child_value())); - if (string(Field.attribute("Name").value()) == "coarsening_factors") { + if (std::string(Field.attribute("Name").value()) == "coarsening_factors") { coarsening_factors.clear(); tokens.clear(); FileUtilities::tokenize(Field.child_value(), ", ", FileUtilities::Trim, &tokens); for (const auto &s : tokens) - coarsening_factors.push_back(stod(s)); + coarsening_factors.push_back(std::stod(s)); } - if (string(Field.attribute("Name").value()) == "initial_level") - initial_level = stoi(Field.child_value()); + if (std::string(Field.attribute("Name").value()) == "initial_level") + initial_level = std::stoi(Field.child_value()); - if (string(Field.attribute("Name").value()) == "domain_expansion_factors") { + if (std::string(Field.attribute("Name").value()) == + "domain_expansion_factors") { domain_expansion_factors.clear(); tokens.clear(); @@ -99,13 +107,13 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, &tokens); for (const auto &s : tokens) - domain_expansion_factors.push_back(stod(s)); + domain_expansion_factors.push_back(std::stod(s)); } - if (string(Field.attribute("Name").value()) == "offset") + if (std::string(Field.attribute("Name").value()) == "offset") offset = FileUtilities::string2Doublearray(Field.child_value()); - if (string(Field.attribute("Name").value()) == "lattice_name") + if (std::string(Field.attribute("Name").value()) == "lattice_name") _name = Field.child_value(); } @@ -113,10 +121,10 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, point<DIM> upper, lower; point<DIM> l; - vector<Box<point<DIM>, DIM>> coarsening_levels(n_coarsening_levels + 1); + std::vector<Box<point<DIM>, DIM>> coarsening_levels(n_coarsening_levels + 1); // read the file here for lattice generation - vector<point<DIM>> coarsening_levels_domains(n_coarsening_levels); + std::vector<point<DIM>> coarsening_levels_domains(n_coarsening_levels); for (int i = 0; i < n_coarsening_levels; i++) { for (int d = 0; d < DIM; d++) { @@ -152,10 +160,10 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, coarsening_levels[0] = Box<point<DIM>, DIM>(coarsening_levels[1].upper_, coarsening_levels[1].lower_); - vector<point<DIM>> seed_points(1); - vector<int> boundary_points; + std::vector<point<DIM>> seed_points(1); + std::vector<int> boundary_points; seed_points[0] = center; - vector<vector<double>> adjusted_basis(DIM); + std::vector<std::vector<double>> adjusted_basis(DIM); // coarsening_factors[0] = initial_level; for (int i_box = 0; i_box < n_coarsening_levels; i_box++) { @@ -186,7 +194,7 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, char buffer[256]; sprintf(buffer, "%06d", int(_lattice_points.size())); - string output_N(buffer); + std::string output_N(buffer); _name = _name + "_" + output_N; @@ -194,4 +202,4 @@ void GenerateLattice(vector<point<DIM>> &_lattice_points, _lattice_points.begin(), _lattice_points.end(), _bounds); cout << "total lattice sites added = " << _lattice_points.size() << endl; -} \ No newline at end of file +} diff --git a/src/lattice/latticeSite.h b/src/lattice/latticeSite.h index 6691793aa..3ec83b1a8 100644 --- a/src/lattice/latticeSite.h +++ b/src/lattice/latticeSite.h @@ -2,19 +2,17 @@ #include "StandardHeaders.h" -using namespace std; - namespace lattice { template <int DIM, int NIDOF> struct latticeSite { - typedef pair<int, size_t> pair_index; + typedef std::pair<int, size_t> pair_index; - array<double, DIM> location_; - array<double, DIM> offset_; - array<double, DIM> relativeDisplNeighbourBuild_; - vector<pair<pair_index, double>> repatom_dependencies_; + std::array<double, DIM> location_; + std::array<double, DIM> offset_; + std::array<double, DIM> relativeDisplNeighbourBuild_; + std::vector<std::pair<pair_index, double>> repatom_dependencies_; #ifdef FINITE_TEMPERATURE - array<double, NIDOF> thermal_coordinate_; + std::array<double, NIDOF> thermal_coordinate_; #endif bool interproc_flag_; @@ -28,13 +26,14 @@ template <int DIM, int NIDOF> struct latticeSite { #endif relativeDisplNeighbourBuild_.fill(0.0); } - latticeSite(const array<double, DIM> &_l, const array<double, DIM> &_offset, - const array<double, DIM + 1> &_N, + latticeSite( + const std::array<double, DIM> &_l, const std::array<double, DIM> &_offset, + const std::array<double, DIM + 1> &_N, #ifdef FINITE_TEMPERATURE - const array<array<double, NIDOF>, DIM + 1> &_thermal_simplex, + const std::array<std::array<double, NIDOF>, DIM + 1> &_thermal_simplex, #endif - const array<size_t, DIM + 1> &_i, const int &_rank, - const bool &_flag, const bool &_periodic_flag) { + const std::array<size_t, DIM + 1> &_i, const int &_rank, + const bool &_flag, const bool &_periodic_flag) { // a new neighbour has no relative displacement // from sampling atom. This is tested for // determining if neighbourhood build is required. @@ -56,7 +55,7 @@ template <int DIM, int NIDOF> struct latticeSite { #endif for (int d = 0; d < DIM + 1; d++) { - _p = make_pair(_rank, _i[d]); + _p = std::make_pair(_rank, _i[d]); if (abs(_N[d]) > 1.0e-4) { repatom_dependencies_.emplace_back(_p, _N[d]); @@ -71,4 +70,4 @@ template <int DIM, int NIDOF> struct latticeSite { double operator[](const int &_d) { return location_[_d]; } }; -} // namespace lattice \ No newline at end of file +} // namespace lattice diff --git a/src/lattice/repatomcontainer.h b/src/lattice/repatomcontainer.h index abdb28ee6..7892710bf 100644 --- a/src/lattice/repatomcontainer.h +++ b/src/lattice/repatomcontainer.h @@ -8,8 +8,6 @@ #include "mpiutilities.h" #include "utilities.h" -using namespace std; - namespace repatoms { // no exchange of repatoms. Just exchange @@ -21,42 +19,43 @@ template <int DIM, int NIDOF> class RepatomContainer { public: // we are using repatom container instead of a vector of repatom objects // so converting all the calculations to a C type petsc array is simple - vector<point<DIM>> locations_; - vector<point<DIM>> forces_; - vector<point<DIM>> velocities_; - vector<bool> ifOnBoundary_; - vector<bool> ifFixed_; + std::vector<point<DIM>> locations_; + std::vector<point<DIM>> forces_; + std::vector<point<DIM>> velocities_; + std::vector<bool> ifOnBoundary_; + std::vector<bool> ifFixed_; - vector<int> ghost_DOF_indices_; + std::vector<int> ghost_DOF_indices_; int noof_ghosts_; #ifdef FINITE_TEMPERATURE typedef array<double, NIDOF> _thermal_point_; - vector<bool> ifThermallyFixed_; + std::vector<bool> ifThermallyFixed_; - vector<_thermal_point_> thermal_coordinates_; //\Omega, \Sigma - vector<double> thermal_forces_; // d\alpha/dt - vector<double> thermal_velocities_; // d\Sigma/dt - vector<double> entropy_; - vector<double> entropy_production_rates_; + std::vector<_thermal_point_> thermal_coordinates_; //\Omega, \Sigma + std::vector<double> thermal_forces_; // d\alpha/dt + std::vector<double> thermal_velocities_; // d\Sigma/dt + std::vector<double> entropy_; + std::vector<double> entropy_production_rates_; - vector<double> dissipative_potential_; + std::vector<double> dissipative_potential_; #endif - vector<int> material_indices_; - vector<double> nodalWeights_; - vector<double> mass_; - vector<int> force_distribution_factors_; + std::vector<int> material_indices_; + std::vector<double> nodalWeights_; + std::vector<double> mass_; + std::vector<int> force_distribution_factors_; #ifdef DEBUG_INTERPROC_NEIGHBOURS // these are important for debug only - vector<vector<point<DIM>>> candidate_forces_; - vector<vector<pair<point<DIM>, point<DIM>>>> dependent_neighbour_bonds_; - vector<vector<double>> dependent_neighbour_bonds_nodalWeights_; - vector<vector<int>> dependent_neighbour_bonds_multiplicity_; + std::vector<std::vector<point<DIM>>> candidate_forces_; + std::vector<std::vector<pair<point<DIM>, point<DIM>>>> + dependent_neighbour_bonds_; + std::vector<std::vector<double>> dependent_neighbour_bonds_nodalWeights_; + std::vector<std::vector<int>> dependent_neighbour_bonds_multiplicity_; #endif - void assignGhostDOFs(const vector<int> &_ghost_node_indices) { + void assignGhostDOFs(const std::vector<int> &_ghost_node_indices) { int nVar = DIM; noof_ghosts_ = _ghost_node_indices.size(); @@ -84,8 +83,9 @@ public: } template <typename BoundaryCondition> - void forceResidual(const vector<BoundaryCondition *> &_boundary_conditions, - double &_r, const bool &_apply_boundary = false) { + void + forceResidual(const std::vector<BoundaryCondition *> &_boundary_conditions, + double &_r, const bool &_apply_boundary = false) { fill(ifOnBoundary_.begin(), ifOnBoundary_.end(), false); if (_apply_boundary) { @@ -211,12 +211,12 @@ public: const double T = exp(-thermal_coordinates_[_id][0]) / k_Boltzmann; if ((T < T_min) || (T > T_max)) { - cout << "rank : " << mpi_rank - << " detected temperature out of provided bounds of, T_min = " - << T_min << " - T_max = " << T_max << " = " << T - << " . There could be a problem now. Relaxation could fail. " - "Exiting..." - << endl; + std::cout << "rank : " << mpi_rank + << " detected temperature out of provided bounds of, T_min = " + << T_min << " - T_max = " << T_max << " = " << T + << " . There could be a problem now. Relaxation could fail. " + "Exiting..." + << std::endl; exit(0); } } @@ -311,9 +311,9 @@ public: } void resize(const size_t &N) { - locations_.resize(N, filled_array<point<DIM>>(0.0)); - forces_.resize(N, filled_array<point<DIM>>(0.0)); - velocities_.resize(N, filled_array<point<DIM>>(0.0)); + locations_.resize(N, std::filled_array<point<DIM>>(0.0)); + forces_.resize(N, std::filled_array<point<DIM>>(0.0)); + velocities_.resize(N, std::filled_array<point<DIM>>(0.0)); ifOnBoundary_.resize(N, false); ifFixed_.resize(N, false); @@ -321,7 +321,7 @@ public: #ifdef FINITE_TEMPERATURE dissipative_potential_.resize(N, 0.0); ifThermallyFixed_.resize(N, false); - thermal_coordinates_.resize(N, filled_array<point<NIDOF>>(0.0)); + thermal_coordinates_.resize(N, std::filled_array<point<NIDOF>>(0.0)); thermal_forces_.resize(N, 0.0); thermal_velocities_.resize(N, 0.0); entropy_.resize(N, 0.0); @@ -334,9 +334,9 @@ public: // push_back empty quantities void push_back() { - locations_.push_back(filled_array<point<DIM>>(0.0)); - forces_.push_back(filled_array<point<DIM>>(0.0)); - velocities_.push_back(filled_array<point<DIM>>(0.0)); + locations_.push_back(std::filled_array<point<DIM>>(0.0)); + forces_.push_back(std::filled_array<point<DIM>>(0.0)); + velocities_.push_back(std::filled_array<point<DIM>>(0.0)); ifOnBoundary_.push_back(false); ifFixed_.push_back(false); @@ -344,7 +344,7 @@ public: #ifdef FINITE_TEMPERATURE dissipative_potential_.push_back(0.0); ifThermallyFixed_.push_back(false); - thermal_coordinates_.push_back(filled_array<point<NIDOF>>(0.0)); + thermal_coordinates_.push_back(std::filled_array<point<NIDOF>>(0.0)); thermal_forces_.push_back(0.0); thermal_velocities_.push_back(0.0); entropy_.push_back(0.0); @@ -373,7 +373,8 @@ public: } void zeroVelocities() { - fill(velocities_.begin(), velocities_.end(), filled_array<point<DIM>>(0.0)); + fill(velocities_.begin(), velocities_.end(), + std::filled_array<point<DIM>>(0.0)); #ifdef FINITE_TEMPERATURE fill(thermal_velocities_.begin(), thermal_velocities_.end(), 0.0); @@ -381,4 +382,4 @@ public: } }; -} // namespace repatoms \ No newline at end of file +} // namespace repatoms diff --git a/src/lattice/repatoms.h b/src/lattice/repatoms.h index 5085f71e7..f960db0b8 100644 --- a/src/lattice/repatoms.h +++ b/src/lattice/repatoms.h @@ -15,8 +15,6 @@ #include "mpiutilities.h" #include "utilities.h" -using namespace std; - namespace repatoms { template <typename point_d, int DIM, int NIDOF> class RepAtom { @@ -35,15 +33,15 @@ public: #ifdef DEBUG_INTERPROC_NEIGHBOURS // these are important for debug only vector<point_d> candidate_forces_; - vector<pair<point_d, point_d>> dependent_neighbour_bonds_; - vector<double> dependent_neighbour_bonds_weights_; - vector<int> dependent_neighbour_bonds_multiplicity_; + std::vector<pair<point_d, point_d>> dependent_neighbour_bonds_; + std::vector<double> dependent_neighbour_bonds_weights_; + std::vector<int> dependent_neighbour_bonds_multiplicity_; #endif int output_marker_; #ifdef FINITE_TEMPERATURE - array<double, NIDOF> internal_dofs_; + std::array<double, NIDOF> internal_dofs_; double thermal_force_; #endif @@ -110,10 +108,10 @@ public: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { - ar & this->location_; - ar & this->velocity_; - ar & this->force_; - ar & this->weight_; + ar &this->location_; + ar &this->velocity_; + ar &this->force_; + ar &this->weight_; }; }; @@ -124,8 +122,8 @@ struct DerefAtomIterator : public std::unary_function<Handle, point> { }; template <typename point_d, int DIM, int NIDOF> -void GetPoints(vector<point_d> &_locations, - const vector<RepAtom<point_d, DIM, NIDOF>> &_atoms) { +void GetPoints(std::vector<point_d> &_locations, + const std::vector<RepAtom<point_d, DIM, NIDOF>> &_atoms) { for (int ip = 0; ip < _atoms.size(); ip++) { point_d p; p = _atoms[ip].location_; @@ -133,8 +131,8 @@ void GetPoints(vector<point_d> &_locations, } } template <typename repatom_d, typename other_point_d, int DIM> -void ConvertRepatomLocations(vector<other_point_d> &_locations, - const vector<repatom_d> &_atoms) { +void ConvertRepatomLocations(std::vector<other_point_d> &_locations, + const std::vector<repatom_d> &_atoms) { for (int ip = 0; ip < _atoms.size(); ip++) { other_point_d p; @@ -145,8 +143,9 @@ void ConvertRepatomLocations(vector<other_point_d> &_locations, } template <typename point_d, int DIM, int NIDOF> -void GetMaterialIndices(vector<int> &_indices, - const vector<RepAtom<point_d, DIM, NIDOF>> &_atoms) { +void GetMaterialIndices( + std::vector<int> &_indices, + const std::vector<RepAtom<point_d, DIM, NIDOF>> &_atoms) { for (int ip = 0; ip < _atoms.size(); ip++) { _indices.push_back(_atoms[ip].material_idx_); } @@ -154,9 +153,9 @@ void GetMaterialIndices(vector<int> &_indices, template <typename point_d, int DIM, int NIDOF> void AssignRepAtomLocationsAndVelocites( - vector<RepAtom<point_d, DIM, NIDOF>> &_atoms, - const vector<point_d> &_atom_locations, - const vector<point_d> &_atom_velocities) { + std::vector<RepAtom<point_d, DIM, NIDOF>> &_atoms, + const std::vector<point_d> &_atom_locations, + const std::vector<point_d> &_atom_velocities) { typedef RepAtom<point_d, DIM, NIDOF> repatom_d; _atoms.reserve(_atom_locations.size()); @@ -173,10 +172,10 @@ void AssignRepAtomLocationsAndVelocites( template <class Box_d, class point_d, class boundary_d, int DIM, int IDOF> void PopulateRepatomsAlmostUniform( const lattice::Lattice<point_d, DIM> &_lattice_obj, - vector<RepAtom<point_d, DIM, IDOF>> &_repatoms, const Box_d _coarsening_box, - const int &_number_of_repatoms_in_box, - const vector<vector<point_d>> &_boundary_sites, - const vector<boundary_d> &_boundaries) { + std::vector<RepAtom<point_d, DIM, IDOF>> &_repatoms, + const Box_d _coarsening_box, const int &_number_of_repatoms_in_box, + const std::vector<std::vector<point_d>> &_boundary_sites, + const std::vector<boundary_d> &_boundaries) { lattice::AssignAllLatticeSitesInBoxAsRepAtoms<RepAtom<point_d, DIM, IDOF>, Box_d, point_d, DIM>( _lattice_obj, _coarsening_box, _repatoms); @@ -185,10 +184,11 @@ void PopulateRepatomsAlmostUniform( template <class Box_d, class point_d, class boundary_d, int DIM, int IDOF> void PopulateRepAtomsFromBoundingBoxes( const lattice::Lattice<point_d, DIM> &_lattice_obj, - vector<RepAtom<point_d, DIM, IDOF>> &_repatoms, - vector<Box_d> _coarsening_boxes, vector<int> _number_of_repatoms_in_box, - const vector<vector<point_d>> &_boundary_sites, - const vector<boundary_d> &_boundaries) { + std::vector<RepAtom<point_d, DIM, IDOF>> &_repatoms, + std::vector<Box_d> _coarsening_boxes, + std::vector<int> _number_of_repatoms_in_box, + const std::vector<std::vector<point_d>> &_boundary_sites, + const std::vector<boundary_d> &_boundaries) { int i_box = 0; lattice::AssignAllLatticeSitesInBoxAsRepAtoms<RepAtom<point_d, DIM, IDOF>, Box_d, point_d, DIM>( @@ -209,7 +209,7 @@ void PopulateRepAtomsFromBoundingBoxes( template <typename point_d, int DIM, int IDOF> void PopulateAllRepatomsLattice( const lattice::Lattice<point_d, DIM> &_lattice_obj, - vector<RepAtom<point_d, DIM, IDOF>> &_repatoms) { + std::vector<RepAtom<point_d, DIM, IDOF>> &_repatoms) { int p_ctr = 0; for (point_d p : _lattice_obj.lattice_sites) { @@ -228,8 +228,8 @@ void PopulateRepAtomsFromMesh(MeshClass _mesh, RepAtomContainer &_repatoms) { template <typename point_d, typename repatom_d, typename boundary_condition, int DIM> void AssignBoundaryConditionIDs( - vector<repatom_d> &_repatoms, - vector<boundary_condition *> &_boundary_conditions) { + std::vector<repatom_d> &_repatoms, + std::vector<boundary_condition *> &_boundary_conditions) { int repatom_ctr = 0; for (repatom_d &atom : _repatoms) { for (int boundary_ctr = 0; boundary_ctr < _boundary_conditions.size(); @@ -255,9 +255,9 @@ void AssignBoundaryConditionIDs( template <typename point_d, typename repatom_d, typename boundary_condition, int DIM> void AssignBoundaryConditionIDs( - vector<repatom_d> &_repatoms, - vector<boundary_condition *> &_boundary_conditions, - const vector<vector<int>> &_node_idxs) { + std::vector<repatom_d> &_repatoms, + std::vector<boundary_condition *> &_boundary_conditions, + const std::vector<std::vector<int>> &_node_idxs) { for (int i_zone = 0; i_zone < _node_idxs.size(); i_zone++) { for (int i_node = 0; i_node < _node_idxs[i_zone].size(); i_node++) { @@ -273,8 +273,8 @@ void AssignBoundaryConditionIDs( } template <typename mesh_d, typename repatom_d, int DIM> -void AssignRepatomWeights(const mesh_d _mesh, vector<repatom_d> &_atoms, - const vector<material<DIM> *> &_materials) { +void AssignRepatomWeights(const mesh_d _mesh, std::vector<repatom_d> &_atoms, + const std::vector<material<DIM> *> &_materials) { // Weights of repatoms // needed for dynamics simulations int repatom_ctr = 0; @@ -303,8 +303,8 @@ void AssignRepatomWeights(const mesh_d _mesh, vector<repatom_d> &_atoms, } } - vector<vector<double>> send_buffer; - vector<vector<double>> recv_buffer; + std::vector<std::vector<double>> send_buffer; + std::vector<std::vector<double>> recv_buffer; mpi_utilities::PackBuffers_AtomsWeights<mesh_d, repatom_d, DIM>( _mesh, send_buffer, recv_buffer, _atoms); @@ -342,9 +342,11 @@ void AssignRepatomWeights(const mesh_d _mesh, vector<repatom_d> &_atoms, template <typename mesh_d, typename repatom_d, typename sampling_atom_d, int DIM> void AssignRepatomWeightsFromSamplingAtoms( - const mesh_d _mesh, const vector<sampling_atom_d> &_nodal_sampling_atoms, - const vector<sampling_atom_d> &_cb_sampling_atoms, - const vector<material<DIM> *> &_materials, vector<repatom_d> &_repatoms) { + const mesh_d _mesh, + const std::vector<sampling_atom_d> &_nodal_sampling_atoms, + const std::vector<sampling_atom_d> &_cb_sampling_atoms, + const std::vector<material<DIM> *> &_materials, + std::vector<repatom_d> &_repatoms) { // Weights of repatoms // needed for dynamics simulations for (int i_nd = 0; i_nd < _mesh.nodes_.size(); ++i_nd) { @@ -365,8 +367,8 @@ void AssignRepatomWeightsFromSamplingAtoms( } // now communicate to account for cb sampling atoms in other ranks - vector<vector<double>> send_buffer; - vector<vector<double>> recv_buffer; + std::vector<std::vector<double>> send_buffer; + std::vector<std::vector<double>> recv_buffer; mpi_utilities::PackBuffers_AtomsWeights<mesh_d, repatom_d, DIM>( _mesh, send_buffer, recv_buffer, _repatoms); @@ -409,7 +411,7 @@ void AssignRepatomWeightsFromSamplingAtoms( } } template <typename repatom_d> -void AssignRepatomPhaseSpace(vector<repatom_d> &_atoms) { +void AssignRepatomPhaseSpace(std::vector<repatom_d> &_atoms) { for (repatom_d &_atom : _atoms) { // Omega _atom.internal_dofs_[0] = _atom.mass_ * k_Boltzmann * T_ref; diff --git a/src/lattice/samplingatoms.h b/src/lattice/samplingatoms.h index f33f6c5f5..591772968 100644 --- a/src/lattice/samplingatoms.h +++ b/src/lattice/samplingatoms.h @@ -14,40 +14,38 @@ #include "mpiutilities.h" #include "utilities.h" -using namespace geometry; - namespace sampling_atoms { template <int DIM, int NIDOF> class SamplingAtomContainer { public: typedef lattice::latticeSite<DIM, NIDOF> atomic_site; - vector<point<DIM>> nodalLocations_; - vector<point<DIM>> centralLocations_; + std::vector<point<DIM>> nodalLocations_; + std::vector<point<DIM>> centralLocations_; #ifdef FINITE_TEMPERATURE - vector<point<NIDOF>> centralIDOFs_; + std::vector<point<NIDOF>> centralIDOFs_; #endif - vector<size_t> cellKeyOfCentralAtoms_; + std::vector<size_t> cellKeyOfCentralAtoms_; - vector<double> nodalWeights_; - vector<double> centralWeights_; + std::vector<double> nodalWeights_; + std::vector<double> centralWeights_; - vector<double> nodalCutOffs_; - vector<double> centralCutOffs_; + std::vector<double> nodalCutOffs_; + std::vector<double> centralCutOffs_; - vector<int> centralMaterialIDs_; + std::vector<int> centralMaterialIDs_; - vector<vector<atomic_site>> nodalSamplingAtomNeighbours_; - vector<vector<atomic_site>> centralSamplingAtomNeighbours_; + std::vector<std::vector<atomic_site>> nodalSamplingAtomNeighbours_; + std::vector<std::vector<atomic_site>> centralSamplingAtomNeighbours_; - vector<point<DIM>> nodalDisplacementsOverlapExchange_; + std::vector<point<DIM>> nodalDisplacementsOverlapExchange_; - vector<double> nodalCentroSymmetry_; + std::vector<double> nodalCentroSymmetry_; - vector<double> nodalEnergies_; - vector<double> centralEnergies_; + std::vector<double> nodalEnergies_; + std::vector<double> centralEnergies_; // // for exchange of weights // Vec nodalWeightsDistPetsc_, nodalWeightsLocalPetsc_; // const PetscReal *localNodalWeightsRead_; @@ -86,12 +84,13 @@ public: // nodal sampling atom locations have to be stored // to compute the deformation. Either store displacement // or store locations. - nodalLocations_.resize(N, filled_array<point<DIM>>(0.0)); + nodalLocations_.resize(N, std::filled_array<point<DIM>>(0.0)); nodalCutOffs_.resize(N, 0.0); nodalWeights_.resize(N, 0.0); nodalSamplingAtomNeighbours_.resize(N); - nodalDisplacementsOverlapExchange_.resize(N, filled_array<point<DIM>>(0.0)); + nodalDisplacementsOverlapExchange_.resize( + N, std::filled_array<point<DIM>>(0.0)); nodalCentroSymmetry_.resize(N, 0.0); @@ -99,12 +98,13 @@ public: } void push_back_nodal() { - nodalLocations_.push_back(filled_array<point<DIM>>(0.0)); + nodalLocations_.push_back(std::filled_array<point<DIM>>(0.0)); nodalCutOffs_.push_back(0.0); nodalWeights_.push_back(0.0); - nodalSamplingAtomNeighbours_.push_back(vector<atomic_site>{}); + nodalSamplingAtomNeighbours_.push_back(std::vector<atomic_site>{}); - nodalDisplacementsOverlapExchange_.push_back(filled_array<point<DIM>>(0.0)); + nodalDisplacementsOverlapExchange_.push_back( + std::filled_array<point<DIM>>(0.0)); nodalCentroSymmetry_.push_back(0.0); @@ -112,7 +112,7 @@ public: } void getCentralNeighbourCluster(const size_t &_index, - vector<point<DIM>> &_clusters) { + std::vector<point<DIM>> &_clusters) { _clusters.clear(); _clusters.reserve(centralSamplingAtomNeighbours_[_index].size()); @@ -122,8 +122,8 @@ public: } void getCentralNeighbourCluster(const size_t &_index, - vector<point<DIM>> &_clusters, - vector<int> &_clusterIndices) { + std::vector<point<DIM>> &_clusters, + std::vector<int> &_clusterIndices) { _clusters.clear(); _clusterIndices.clear(); @@ -146,7 +146,7 @@ public: } void getNodalNeighbourCluster(const size_t &_index, - vector<point<DIM>> &_clusters) const { + std::vector<point<DIM>> &_clusters) const { _clusters.clear(); _clusters.reserve(nodalSamplingAtomNeighbours_[_index].size()); @@ -157,8 +157,8 @@ public: } void getNodalNeighbourCluster(const size_t &_index, - vector<point<DIM>> &_clusters, - vector<int> &_clusterIndices) const { + std::vector<point<DIM>> &_clusters, + std::vector<int> &_clusterIndices) const { _clusters.clear(); _clusterIndices.clear(); @@ -182,8 +182,8 @@ public: double getNodalCentroSymmetry(const size_t &_index, - const vector<point<DIM>> &_centroSymmetry) const { - array<point<DIM>, 2> mirrorDirs; + const std::vector<point<DIM>> &_centroSymmetry) const { + std::array<point<DIM>, 2> mirrorDirs; mirrorDirs[0].fill(0.0); mirrorDirs[1].fill(0.0); @@ -241,10 +241,11 @@ public: } #ifdef FINITE_TEMPERATURE - void getCentralNeighbourThermalCluster(const size_t &_index, - vector<point<DIM>> &_cluster, - vector<point<NIDOF>> &_thermalCluster, - vector<int> &_clusterIndices) { + void + getCentralNeighbourThermalCluster(const size_t &_index, + std::vector<point<DIM>> &_cluster, + std::vector<point<NIDOF>> &_thermalCluster, + std::vector<int> &_clusterIndices) { _cluster.clear(); _thermalCluster.clear(); _clusterIndices.clear(); @@ -266,10 +267,11 @@ public: } } - void getNodalNeighbourThermalCluster(const size_t &_index, - vector<point<DIM>> &_cluster, - vector<point<NIDOF>> &_thermalCluster, - vector<int> &_clusterIndices) { + void + getNodalNeighbourThermalCluster(const size_t &_index, + std::vector<point<DIM>> &_cluster, + std::vector<point<NIDOF>> &_thermalCluster, + std::vector<int> &_clusterIndices) { _cluster.clear(); _thermalCluster.clear(); _clusterIndices.clear(); @@ -296,7 +298,7 @@ public: template <int DIM, int NIDOF> class SamplingAtom { public: typedef lattice::latticeSite<DIM, NIDOF> atomic_site; - typedef pair<int, int> pair_index; + typedef std::pair<int, int> pair_index; public: double weight_; @@ -315,27 +317,27 @@ public: size_t index_of_element_; point<DIM> location_; - // vector<point_d> neighbour_points_; + // std::vector<point_d> neighbour_points_; - vector<atomic_site> neighbour_sites_; + std::vector<atomic_site> neighbour_sites_; /*! other proc neighbours. They will add forces on their repatoms and communicate */ - // vector<vector<int>> DependentRepAtoms; + // std::vector<std::vector<int>> DependentRepAtoms; /** * Shape function values of repatoms * at Nk(neighbours) * Should have identical shape as DependentRepAtoms */ - // vector<vector<double>> ShapeFunctionsRepAtomsAtNeighbours; + // std::vector<std::vector<double>> ShapeFunctionsRepAtomsAtNeighbours; - // vector<double> NeighbourForces_magnitudes; - // vector<point_d> NeighbourForces; + // std::vector<double> NeighbourForces_magnitudes; + // std::vector<point_d> NeighbourForces; #ifdef FINITE_TEMPERATURE - array<double, NIDOF> thermal_coordinate_; + std::array<double, NIDOF> thermal_coordinate_; // double Sigma_; // double Omega_; #endif @@ -346,7 +348,7 @@ public: * a repatom. */ - // vector<double> WeightsOfSamplingAtom; + // std::vector<double> WeightsOfSamplingAtom; /** * Material index of the sampling atom @@ -355,11 +357,11 @@ public: int multiplicity_; // set<int> ConnectedProcs; - // vector<int> ConnectedProcs; - // vector<int> ConnectedSeedElementIds; + // std::vector<int> ConnectedProcs; + // std::vector<int> ConnectedSeedElementIds; // only stored if the queries are being output - // vector<int> neighbour_element_local_idxs_; + // std::vector<int> neighbour_element_local_idxs_; // If neighbourhoods extend to other processors bool IsAtProcBoundary; @@ -421,17 +423,17 @@ public: template <typename mesh_d, typename point_d, typename SamplingAtom, typename repatomContainer, int DIM> void CreateOptimalSamplingAtomsFromMesh( - mesh_d &_mesh, vector<SamplingAtom> &_nodal_sampling_atoms, - vector<SamplingAtom> &_cb_sampling_atoms, + mesh_d &_mesh, std::vector<SamplingAtom> &_nodal_sampling_atoms, + std::vector<SamplingAtom> &_cb_sampling_atoms, const repatomContainer &_localRepatomContainer, - const vector<material<DIM> *> &_materials) { + const std::vector<material<DIM> *> &_materials) { - vector<int> nodeidxtosamplingidx; + std::vector<int> nodeidxtosamplingidx; // Need sorted elements for staying closeby // Hence the vertices can be looped over for closer // nodal sampling atoms // Add barycenters by elements - array<bool, DIM + 1> enableSides; + std::array<bool, DIM + 1> enableSides; int sampleidx = 0; // Adding mesh nodes as sampling atoms @@ -472,18 +474,18 @@ void CreateOptimalSamplingAtomsFromMesh( // int i_el = 0; // double elementvolume = _mesh.MeshElements[i_el].volume; - // array<double, DIM+1> nodeVolumes; - // array<double, DIM+1> sideVolumes; + // std::array<double, DIM+1> nodeVolumes; + // std::array<double, DIM+1> sideVolumes; // double barycenterVolume; - // array<point_d, DIM+1> simplex; - // cout<<mpi_rank<<" testing tesselation of "<<endl; + // std::array<point_d, DIM+1> simplex; + // std::cout<<mpi_rank<<" testing tesselation of "<<std::endl; // for(int d=0; d<DIM + 1; d++) // { // simplex[d]=_mesh.MeshNodes[_mesh.MeshElements[i_el].VerticesOfElement[d]]; // for(int dn=0; dn<DIM; dn++) - // cout<<simplex[d].coords_[dn]<<" , "; + // std::cout<<simplex[d].coords_[dn]<<" , "; - // cout<<endl; + // std::cout<<std::endl; // enableSides[d] = false; // } @@ -498,9 +500,9 @@ void CreateOptimalSamplingAtomsFromMesh( double element_jacobian; double element_density; - array<point_d, DIM + 1> simplex; - array<double, DIM + 1> angles; - array<double, DIM + 1> node_volumes; + std::array<point_d, DIM + 1> simplex; + std::array<double, DIM + 1> angles; + std::array<double, DIM + 1> node_volumes; double barycenter_volume, node_radius, side_radius; @@ -565,10 +567,10 @@ void CreateOptimalSamplingAtomsFromMesh( // if(_mesh.simplices_.at(i_el)[d]==237) // { // contribution+=node_volumes[d]*element_density; - // cout<<node_volumes[0]<<" , "<<node_volumes[1]<<" , - // "<<node_volumes[2]<<" , "<<node_volumes[3]<<endl; cout<<angles[0]<<" , - // "<<angles[1]<<" , "<<angles[2]<<" , "<<angles[3]<<endl; - // cout<<barycenterweight<<endl; + // std::cout<<node_volumes[0]<<" , "<<node_volumes[1]<<" , + // "<<node_volumes[2]<<" , "<<node_volumes[3]<<std::endl; std::cout<<angles[0]<<" , + // "<<angles[1]<<" , "<<angles[2]<<" , "<<angles[3]<<std::endl; + // std::cout<<barycenterweight<<std::endl; // } } @@ -636,8 +638,8 @@ void CreateOptimalSamplingAtomsFromMesh( // if(_mesh.simplices_.at(i_el)[d]==237) // { // contribution+=barycenterweight*angles[d]/total_angles; - // cout<<"total contribution from this element - // "<<contribution<<endl; + // std::cout<<"total contribution from this element + // "<<contribution<<std::endl; // } } } @@ -649,8 +651,8 @@ void CreateOptimalSamplingAtomsFromMesh( // exchange weights for connected nodes // for buffer - vector<vector<double>> send_buffer; - vector<vector<double>> recv_buffer; + std::vector<std::vector<double>> send_buffer; + std::vector<std::vector<double>> recv_buffer; mpi_utilities::PackBuffers_AtomsWeights<mesh_d, SamplingAtom, DIM>( _mesh, send_buffer, recv_buffer, _nodal_sampling_atoms); @@ -679,10 +681,10 @@ void CreateOptimalSamplingAtomsFromMesh( // if(_nodal_sampling_atoms[n_sa].weight_<0.99) // { // f_MIN<<_nodal_sampling_atoms[n_sa].location_[0]<<" - // "<<_nodal_sampling_atoms[n_sa].location_[1]<<endl; - // cout<<_nodal_sampling_atoms[n_sa].location_[0]<<" , " + // "<<_nodal_sampling_atoms[n_sa].location_[1]<<std::endl; + // std::cout<<_nodal_sampling_atoms[n_sa].location_[0]<<" , " // <<_nodal_sampling_atoms[n_sa].location_[1]<<" , "<< - // _nodal_sampling_atoms[n_sa].weight_<<endl; + // _nodal_sampling_atoms[n_sa].weight_<<std::endl; // } // } // f_MIN.close(); @@ -693,7 +695,7 @@ void CreateOptimalSamplingAtomsFromMesh( // { // f_sampling_atoms<<_nodal_sampling_atoms[n_sa].location_[0]<<" // "<<_nodal_sampling_atoms[n_sa].location_[1]<<" "<< - // _nodal_sampling_atoms[n_sa].weight_<<endl; + // _nodal_sampling_atoms[n_sa].weight_<<std::endl; // } // f_sampling_atoms.close(); // } @@ -703,8 +705,8 @@ template <typename mesh_d, typename sampling_atom, typename repatomContainer, int DIM> void updateThermalDOFs(const mesh_d &_local_mesh, const repatomContainer &_localRepatomContainer, - vector<sampling_atom> &_nodal_sampling_atoms, - vector<sampling_atom> &_cb_sampling_atoms) { + std::vector<sampling_atom> &_nodal_sampling_atoms, + std::vector<sampling_atom> &_cb_sampling_atoms) { for (sampling_atom &atom : _nodal_sampling_atoms) { atom.thermal_coordinate_ = _localRepatomContainer.thermal_coordinates_[atom.index_of_repatom_]; @@ -727,9 +729,9 @@ void updateThermalDOFs(const mesh_d &_local_mesh, } template <typename mesh_d, typename sampling_atom, int DIM> -void UpdateSamplingAtomLocations(const mesh_d &_mesh, - vector<sampling_atom> &_nodal_sampling_atoms, - vector<sampling_atom> &_cb_sampling_atoms) { +void UpdateSamplingAtomLocations( + const mesh_d &_mesh, std::vector<sampling_atom> &_nodal_sampling_atoms, + std::vector<sampling_atom> &_cb_sampling_atoms) { size_t element_of_atom; int node_of_atom; @@ -753,10 +755,10 @@ void UpdateSamplingAtomLocations(const mesh_d &_mesh, } template <typename mesh_d, typename sampling_atom, int DIM> -void UpdateSamplingAtomWeights(const mesh_d &_mesh, - vector<sampling_atom> &_nodal_sampling_atoms, - vector<sampling_atom> &_cb_sampling_atoms, - const vector<material<DIM> *> &_materials) { +void UpdateSamplingAtomWeights( + const mesh_d &_mesh, std::vector<sampling_atom> &_nodal_sampling_atoms, + std::vector<sampling_atom> &_cb_sampling_atoms, + const std::vector<material<DIM> *> &_materials) { for (sampling_atom &atom : _nodal_sampling_atoms) { atom.weight_ = 0.0; } @@ -768,9 +770,9 @@ void UpdateSamplingAtomWeights(const mesh_d &_mesh, double element_jacobian; double element_density; - array<point<DIM>, DIM + 1> simplex; - array<double, DIM + 1> angles; - array<double, DIM + 1> node_volumes; + std::array<point<DIM>, DIM + 1> simplex; + std::array<double, DIM + 1> angles; + std::array<double, DIM + 1> node_volumes; double barycenter_volume, node_radius, side_radius; double total_angles; @@ -809,15 +811,15 @@ void UpdateSamplingAtomWeights(const mesh_d &_mesh, #ifdef CHECK_FOR_NAN if (std::isnan(node_volumes[d])) { - cout << "detected node volume Nan for element " << endl; - cout << simplex[0] << endl; - cout << simplex[1] << endl; - cout << simplex[2] << endl; - cout << simplex[3] << endl; - - cout << "element jacobian " << element_jacobian << endl; - cout << "node radius " << node_radius << endl; - cout << "solid angle " << angles[d] << endl; + std::cout << "detected node volume Nan for element " << std::endl; + std::cout << simplex[0] << std::endl; + std::cout << simplex[1] << std::endl; + std::cout << simplex[2] << std::endl; + std::cout << simplex[3] << std::endl; + + std::cout << "element jacobian " << element_jacobian << std::endl; + std::cout << "node radius " << node_radius << std::endl; + std::cout << "solid angle " << angles[d] << std::endl; } #endif } @@ -847,8 +849,8 @@ void UpdateSamplingAtomWeights(const mesh_d &_mesh, } } - vector<vector<double>> send_buffer; - vector<vector<double>> recv_buffer; + std::vector<std::vector<double>> send_buffer; + std::vector<std::vector<double>> recv_buffer; mpi_utilities::PackBuffers_AtomsWeights<mesh_d, sampling_atom, DIM>( _mesh, send_buffer, recv_buffer, _nodal_sampling_atoms); diff --git a/src/lattice/samplingatomsweightcalculators.h b/src/lattice/samplingatomsweightcalculators.h index 47fc10eeb..f504b2a69 100644 --- a/src/lattice/samplingatomsweightcalculators.h +++ b/src/lattice/samplingatomsweightcalculators.h @@ -405,4 +405,4 @@ void tessellateElement(array<PointClass, DIM + 1> &_simplex, } } // namespace SamplingWeightCalculators -#endif \ No newline at end of file +#endif diff --git a/src/lattice/uniqueLatticeSiteContainer.h b/src/lattice/uniqueLatticeSiteContainer.h index 3d6fe35b6..a089071f8 100644 --- a/src/lattice/uniqueLatticeSiteContainer.h +++ b/src/lattice/uniqueLatticeSiteContainer.h @@ -6,8 +6,6 @@ #include "geometry.h" #include "variables.h" -using namespace std; - namespace lattice { template <typename site, int DIM> class uniqueLatticeSiteContainer { @@ -15,15 +13,16 @@ public: typedef geom::BBox<double, 3> box; typedef geom::Ball<double, 3> ball; - typedef geom::Octree<Dereference<typename vector<point<3>>::const_iterator>> + typedef geom::Octree< + Dereference<typename std::vector<point<3>>::const_iterator>> octree; public: const double tolerance_; ball bounds_; - vector<site> sites_; // important to reserve + std::vector<site> sites_; // important to reserve octree orq_; - vector<typename vector<point<3>>::const_iterator> points_in_query_; + std::vector<typename std::vector<point<3>>::const_iterator> points_in_query_; public: uniqueLatticeSiteContainer() @@ -132,4 +131,4 @@ public: site operator[](const size_t &_id) { return sites_[_id]; } }; -} // namespace lattice \ No newline at end of file +} // namespace lattice diff --git a/src/lattice/uniqueLatticeSiteList.h b/src/lattice/uniqueLatticeSiteList.h index 0c75044c1..cd6fbecb8 100644 --- a/src/lattice/uniqueLatticeSiteList.h +++ b/src/lattice/uniqueLatticeSiteList.h @@ -6,8 +6,6 @@ #include "geometry.h" #include "variables.h" -using namespace std; - namespace lattice { template <typename site, int DIM> class uniqueLatticeSiteList { @@ -15,15 +13,16 @@ public: typedef geom::BBox<double, 3> box; typedef geom::Ball<double, 3> ball; - typedef geom::Octree<Dereference<typename list<point<3>>::const_iterator>> + typedef geom::Octree< + Dereference<typename std::list<point<3>>::const_iterator>> octree; public: const double tolerance_; ball bounds_; - list<site> sites_; // important to reserve + std::list<site> sites_; // important to reserve octree orq_; - vector<typename list<point<3>>::const_iterator> points_in_query_; + std::vector<typename std::list<point<3>>::const_iterator> points_in_query_; bool constrained_; int constrainedDim_; @@ -130,9 +129,9 @@ public: query_window); if (points_in_query_.size() >= 2) { - cout << "lattice site matched with " << _p << endl; + std::cout << "lattice site matched with " << _p << std::endl; for (const auto &i : points_in_query_) { - cout << "matched with" << *i << endl; + std::cout << "matched with" << *i << std::endl; } } @@ -180,4 +179,4 @@ public: size_t size() { return sites_.size(); } }; -} // namespace lattice \ No newline at end of file +} // namespace lattice diff --git a/src/materials/copper/copper.h b/src/materials/copper/copper.h index 339f24d24..92c638ef4 100644 --- a/src/materials/copper/copper.h +++ b/src/materials/copper/copper.h @@ -4,8 +4,8 @@ template <int DIM> class copper : public material<DIM> { public: - typedef array<double, DIM> point; - typedef array<double, NIDOF> thermalPoint; + typedef std::array<double, DIM> point; + typedef std::array<double, NIDOF> thermalPoint; typedef Eigen::Matrix<double, DIM, DIM> matrix; LatticeStructure getLatticeStructure() { @@ -22,19 +22,20 @@ public: virtual void AssignBasisVectors(const matrix _M) {} virtual void getClusterEnergy(double &, const point &, - const vector<point> &) = 0; + const std::vector<point> &) = 0; virtual void getThermalizedEnergy_3(double &, const point &, const thermalPoint &, - const vector<point> &, - const vector<thermalPoint> &) = 0; + const std::vector<point> &, + const std::vector<thermalPoint> &) = 0; - virtual void getClusterForces(vector<point> &, const point &, - const vector<point> &) = 0; + virtual void getClusterForces(std::vector<point> &, const point &, + const std::vector<point> &) = 0; - virtual void getThermalizedForces_3(vector<point> &, vector<double> &, - vector<double> &, const point &, + virtual void getThermalizedForces_3(std::vector<point> &, + std::vector<double> &, + std::vector<double> &, const point &, const thermalPoint &, - const vector<point> &, - const vector<thermalPoint> &) = 0; + const std::vector<point> &, + const std::vector<thermalPoint> &) = 0; }; diff --git a/src/materials/copper/copperExtendedFinnisSinclair.h b/src/materials/copper/copperExtendedFinnisSinclair.h index cbd6fd2d0..7aec704b6 100644 --- a/src/materials/copper/copperExtendedFinnisSinclair.h +++ b/src/materials/copper/copperExtendedFinnisSinclair.h @@ -2,24 +2,22 @@ #include "copper.h" -using namespace std; - // Extended FinnisSinclair :- See Dai et al. 2006 (J. Phys.:Condensed Matter) // copper template <int DIM> class ExtendedFinnisSinclairCopper : public copper<DIM> { double min_rho_; - typedef array<double, DIM> point; - typedef array<double, NIDOF> thermalPoint; + typedef std::array<double, DIM> point; + typedef std::array<double, NIDOF> thermalPoint; typedef Eigen::Matrix<double, DIM, DIM> matrix; public: ExtendedFinnisSinclairCopper() : min_rho_(1.0e-5) {} bool GetEAMFlag() { return true; } - array<double, DIM> getCellDimensions() const { + std::array<double, DIM> getCellDimensions() const { if (DIM == 2) { - array<double, DIM> returnVal; + std::array<double, DIM> returnVal; // this is the energy minimum for this potential, // obtained using the LatticeSpacing executable // returnVal[0] = 2.475547477961683285; @@ -27,21 +25,21 @@ public: returnVal[1] = sin(PI / 3.) * 2.0 * returnVal[0]; return returnVal; } else if (DIM == 3) { - array<double, DIM> returnVal; + std::array<double, DIM> returnVal; // returnVal[0] = 3.551966425; returnVal[0] = 3.61; returnVal[1] = returnVal[0]; returnVal[2] = returnVal[0]; return returnVal; } else { - cout << "invalid spatial dimension. Should be 2 or 3, but got " << DIM - << endl; + std::cout << "invalid spatial dimension. Should be 2 or 3, but got " + << DIM << std::endl; exit(0); } } void AssignBasisVectors(const matrix _M) { - array<double, DIM> UnitCell = this->getCellDimensions(); + std::array<double, DIM> UnitCell = this->getCellDimensions(); if (DIM == 2) { this->BasisVectors[0][0] = UnitCell[0]; @@ -50,7 +48,7 @@ public: this->BasisVectors[0][1] = cos(PI / 3.0) * UnitCell[0]; this->BasisVectors[1][1] = sin(PI / 3.0) * UnitCell[0]; } else if (DIM == 3) { - array<double, DIM * DIM> basis; + std::array<double, DIM * DIM> basis; basis[0] = UnitCell[0] / 2.0; basis[1] = UnitCell[0] / 2.0; @@ -69,8 +67,8 @@ public: matrix basis_prime = Eigen::Map<matrix>(basis.data(), DIM, DIM).transpose() * _M; if (mpi_rank == 0) { - cout << Eigen::Map<matrix>(basis.data(), DIM, DIM) << endl; - cout << basis_prime << endl; + std::cout << Eigen::Map<matrix>(basis.data(), DIM, DIM) << std::endl; + std::cout << basis_prime << std::endl; } for (int i = 0; i < DIM; i++) { @@ -94,8 +92,8 @@ public: } void getCentrosymmetryNeighbourhood(const bool &_constrained, - vector<point> &_centroSymmetries) { - array<double, DIM> UnitCell = this->getCellDimensions(); + std::vector<point> &_centroSymmetries) { + std::array<double, DIM> UnitCell = this->getCellDimensions(); _centroSymmetries.clear(); const double a = UnitCell[0] / 2.0; @@ -115,11 +113,13 @@ public: _centroSymmetries.push_back({{0, -a, a}}); } } - void setName(const string &_name) {} + void setName(const std::string &_name) {} - string getMaterialName() { return string("ExtendedFinnisSinclairCopper"); } + std::string getMaterialName() { + return std::string("ExtendedFinnisSinclairCopper"); + } - string getLatticeStructureName() { + std::string getLatticeStructureName() { return GET_VARIABLE_NAME(getLatticeStructure()); } @@ -135,8 +135,8 @@ public: } else if (DIM == 3) { return -3.49029024191736; } else { - cout << "invalid spatial dimension. Should be 2 or 3, but got " << DIM - << endl; + std::cout << "invalid spatial dimension. Should be 2 or 3, but got " + << DIM << std::endl; exit(0); } } @@ -219,7 +219,7 @@ public: } void getClusterEnergy(double &_U, const point &_atom, - const vector<point> &_neighbours) { + const std::vector<point> &_neighbours) { _U = 0.0; double rho_e, f_rho_e, phi_ij, r_ij_mag; @@ -241,8 +241,8 @@ public: } } - void getClusterForces(vector<point> &_forces, const point &_atom, - const vector<point> &_neighbours) { + void getClusterForces(std::vector<point> &_forces, const point &_atom, + const std::vector<point> &_neighbours) { _forces.clear(); _forces.reserve(_neighbours.size()); @@ -269,7 +269,7 @@ public: if (r_ij_mag <= getNeighborInteractionCutoffRadius()) { _forces.push_back(f_ij_mag * (neighbour - _atom) / r_ij_mag); } else { - _forces.push_back(filled_array<point>(0.0)); + _forces.push_back(std::filled_array<point>(0.0)); } } } @@ -277,8 +277,8 @@ public: void getThermalizedEnergy_3( double &_U, const point &_atom, const thermalPoint &_atomThermalCoordinates, - const vector<point> &_neighbours, - const vector<thermalPoint> &_neighboursThermalCoordinates) { + const std::vector<point> &_neighbours, + const std::vector<thermalPoint> &_neighboursThermalCoordinates) { _U = 0.0; int noof_neighbours, noof_scalars, noof_quadrature_samples, @@ -288,7 +288,7 @@ public: point r_ij, quad_point, sampling_atom_shift, neighbour_shift; - vector<point> neighbour_shifts; + std::vector<point> neighbour_shifts; neighbour_shifts.reserve(200); noof_neighbours = _neighbours.size(); @@ -330,11 +330,12 @@ public: sampling_atom_shift + _atom); if (std::isnan(r_ij_mag)) { - cout << "nan distance detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << endl; + std::cout << "nan distance detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << std::endl; exit(0); } @@ -357,12 +358,13 @@ public: _U += w_quad * phi_ij; if (std::isnan(_U)) { - cout << "nan poitential detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << " , " << r_ij_mag << " , " - << phi_ij << " , " << f_rho_e << endl; + std::cout << "nan poitential detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << " , " << r_ij_mag << " , " << phi_ij << " , " << f_rho_e + << std::endl; exit(0); } } @@ -370,16 +372,17 @@ public: } void getThermalizedForces_3( - vector<point> &_forces, vector<double> &_thermal_forces_sampling_atom, - vector<double> &_thermal_forces_neighbours, const point &_atom, + std::vector<point> &_forces, + std::vector<double> &_thermal_forces_sampling_atom, + std::vector<double> &_thermal_forces_neighbours, const point &_atom, const thermalPoint &_atomThermalCoordinates, - const vector<point> &_neighbours, - const vector<thermalPoint> &_neighboursThermalCoordinates) { + const std::vector<point> &_neighbours, + const std::vector<thermalPoint> &_neighboursThermalCoordinates) { _forces.clear(); _thermal_forces_sampling_atom.clear(); _thermal_forces_neighbours.clear(); - _forces.resize(_neighbours.size(), filled_array<point>(0.0)); + _forces.resize(_neighbours.size(), std::filled_array<point>(0.0)); _thermal_forces_sampling_atom.resize(_neighbours.size(), 0.0); _thermal_forces_neighbours.resize(_neighbours.size(), 0.0); @@ -392,7 +395,7 @@ public: point f_ij, r_ij, quad_point, sampling_atom_shift, neighbour_shift; - vector<point> neighbour_shifts; + std::vector<point> neighbour_shifts; neighbour_shifts.reserve(200); noof_neighbours = _neighbours.size(); @@ -434,11 +437,12 @@ public: sampling_atom_shift + _atom); if (std::isnan(r_ij_mag)) { - cout << "nan distance detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << endl; + std::cout << "nan distance detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << std::endl; exit(0); } @@ -472,13 +476,14 @@ public: double(DIM); if (std::isnan(f_ij_mag)) { - cout << "nan force detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << " , " << r_ij_mag << " , " - << ComputePairPotentialDerivative(r_ij_mag) << " , " << dfrho_e - << endl; + std::cout << "nan force detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << " , " << r_ij_mag << " , " + << ComputePairPotentialDerivative(r_ij_mag) << " , " + << dfrho_e << std::endl; exit(0); } } diff --git a/src/materials/copper/copperJohnson.h b/src/materials/copper/copperJohnson.h index f13dff558..15fd76442 100644 --- a/src/materials/copper/copperJohnson.h +++ b/src/materials/copper/copperJohnson.h @@ -2,15 +2,13 @@ #include "copper.h" -using namespace std; - // Extended FinnisSinclair :- See Dai et al. 2006 (J. Phys.:Condensed Matter) // copper template <int DIM> class JohnsonCopper : public copper<DIM> { double min_rho_; - typedef array<double, DIM> point; - typedef array<double, NIDOF> thermalPoint; + typedef std::array<double, DIM> point; + typedef std::array<double, NIDOF> thermalPoint; typedef Eigen::Matrix<double, DIM, DIM> matrix; JohnsonInformation johnsonInformation_; @@ -21,9 +19,9 @@ public: } bool GetEAMFlag() { return true; } - array<double, DIM> getCellDimensions() const { + std::array<double, DIM> getCellDimensions() const { if (DIM == 2) { - array<double, DIM> returnVal; + std::array<double, DIM> returnVal; // this is the energy minimum for this potential, // obtained using the LatticeSpacing executable // returnVal[0] = 2.475547477961683285; @@ -31,21 +29,21 @@ public: returnVal[1] = sin(PI / 3.) * 2.0 * returnVal[0]; return returnVal; } else if (DIM == 3) { - array<double, DIM> returnVal; + std::array<double, DIM> returnVal; // returnVal[0] = 3.551966425; returnVal[0] = 3.61; returnVal[1] = returnVal[0]; returnVal[2] = returnVal[0]; return returnVal; } else { - cout << "invalid spatial dimension. Should be 2 or 3, but got " << DIM - << endl; + std::cout << "invalid spatial dimension. Should be 2 or 3, but got " + << DIM << std::endl; exit(0); } } void AssignBasisVectors(const matrix _M) { - array<double, DIM> UnitCell = this->getCellDimensions(); + std::array<double, DIM> UnitCell = this->getCellDimensions(); if (DIM == 2) { this->BasisVectors[0][0] = UnitCell[0]; @@ -54,7 +52,7 @@ public: this->BasisVectors[0][1] = cos(PI / 3.0) * UnitCell[0]; this->BasisVectors[1][1] = sin(PI / 3.0) * UnitCell[0]; } else if (DIM == 3) { - array<double, DIM * DIM> basis; + std::array<double, DIM * DIM> basis; basis[0] = UnitCell[0] / 2.0; basis[1] = UnitCell[0] / 2.0; @@ -73,8 +71,8 @@ public: matrix basis_prime = Eigen::Map<matrix>(basis.data(), DIM, DIM).transpose() * _M; if (mpi_rank == 0) { - cout << Eigen::Map<matrix>(basis.data(), DIM, DIM) << endl; - cout << basis_prime << endl; + std::cout << Eigen::Map<matrix>(basis.data(), DIM, DIM) << std::endl; + std::cout << basis_prime << std::endl; } for (int i = 0; i < DIM; i++) { @@ -86,8 +84,8 @@ public: } void getCentrosymmetryNeighbourhood(const bool &_constrained, - vector<point> &_centroSymmetries) { - array<double, DIM> UnitCell = this->getCellDimensions(); + std::vector<point> &_centroSymmetries) { + std::array<double, DIM> UnitCell = this->getCellDimensions(); _centroSymmetries.clear(); const double a = UnitCell[0] / 2.0; @@ -107,11 +105,11 @@ public: _centroSymmetries.push_back({{0, -a, a}}); } } - void setName(const string &_name) {} + void setName(const std::string &_name) {} - string getMaterialName() { return string("JohnsonCopper"); } + std::string getMaterialName() { return std::string("JohnsonCopper"); } - string getLatticeStructureName() { + std::string getLatticeStructureName() { return GET_VARIABLE_NAME(getLatticeStructure()); } @@ -126,8 +124,8 @@ public: } else if (DIM == 3) { return -3.49029024191736; } else { - cout << "invalid spatial dimension. Should be 2 or 3, but got " << DIM - << endl; + std::cout << "invalid spatial dimension. Should be 2 or 3, but got " + << DIM << std::endl; exit(0); } } @@ -207,7 +205,7 @@ public: } void getClusterEnergy(double &_U, const point &_atom, - const vector<point> &_neighbours) { + const std::vector<point> &_neighbours) { _U = 0.0; double rho_e, f_rho_e, phi_ij, r_ij_mag; @@ -229,8 +227,8 @@ public: } } - void getClusterForces(vector<point> &_forces, const point &_atom, - const vector<point> &_neighbours) { + void getClusterForces(std::vector<point> &_forces, const point &_atom, + const std::vector<point> &_neighbours) { _forces.clear(); _forces.reserve(_neighbours.size()); @@ -257,7 +255,7 @@ public: if (r_ij_mag <= getNeighborInteractionCutoffRadius()) { _forces.push_back(f_ij_mag * (neighbour - _atom) / r_ij_mag); } else { - _forces.push_back(filled_array<point>(0.0)); + _forces.push_back(std::filled_array<point>(0.0)); } } } @@ -265,8 +263,8 @@ public: void getThermalizedEnergy_3( double &_U, const point &_atom, const thermalPoint &_atomThermalCoordinates, - const vector<point> &_neighbours, - const vector<thermalPoint> &_neighboursThermalCoordinates) { + const std::vector<point> &_neighbours, + const std::vector<thermalPoint> &_neighboursThermalCoordinates) { _U = 0.0; int noof_neighbours, noof_scalars, noof_quadrature_samples, @@ -276,7 +274,7 @@ public: point r_ij, quad_point, sampling_atom_shift, neighbour_shift; - vector<point> neighbour_shifts; + std::vector<point> neighbour_shifts; neighbour_shifts.reserve(200); noof_neighbours = _neighbours.size(); @@ -318,11 +316,12 @@ public: sampling_atom_shift + _atom); if (std::isnan(r_ij_mag)) { - cout << "nan distance detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << endl; + std::cout << "nan distance detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << std::endl; exit(0); } @@ -345,12 +344,13 @@ public: _U += w_quad * phi_ij; if (std::isnan(_U)) { - cout << "nan poitential detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << " , " << r_ij_mag << " , " - << phi_ij << " , " << f_rho_e << endl; + std::cout << "nan poitential detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << " , " << r_ij_mag << " , " << phi_ij << " , " << f_rho_e + << std::endl; exit(0); } } @@ -358,16 +358,17 @@ public: } void getThermalizedForces_3( - vector<point> &_forces, vector<double> &_thermal_forces_sampling_atom, - vector<double> &_thermal_forces_neighbours, const point &_atom, + std::vector<point> &_forces, + std::vector<double> &_thermal_forces_sampling_atom, + std::vector<double> &_thermal_forces_neighbours, const point &_atom, const thermalPoint &_atomThermalCoordinates, - const vector<point> &_neighbours, - const vector<thermalPoint> &_neighboursThermalCoordinates) { + const std::vector<point> &_neighbours, + const std::vector<thermalPoint> &_neighboursThermalCoordinates) { _forces.clear(); _thermal_forces_sampling_atom.clear(); _thermal_forces_neighbours.clear(); - _forces.resize(_neighbours.size(), filled_array<point>(0.0)); + _forces.resize(_neighbours.size(), std::filled_array<point>(0.0)); _thermal_forces_sampling_atom.resize(_neighbours.size(), 0.0); _thermal_forces_neighbours.resize(_neighbours.size(), 0.0); @@ -380,7 +381,7 @@ public: point f_ij, r_ij, quad_point, sampling_atom_shift, neighbour_shift; - vector<point> neighbour_shifts; + std::vector<point> neighbour_shifts; neighbour_shifts.reserve(200); noof_neighbours = _neighbours.size(); @@ -422,11 +423,12 @@ public: sampling_atom_shift + _atom); if (std::isnan(r_ij_mag)) { - cout << "nan distance detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << endl; + std::cout << "nan distance detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << std::endl; exit(0); } @@ -458,13 +460,14 @@ public: double(DIM); if (std::isnan(f_ij_mag)) { - cout << "nan force detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << " , " << r_ij_mag << " , " - << ComputePairPotentialDerivative(r_ij_mag) << " , " << dfrho_e - << endl; + std::cout << "nan force detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << " , " << r_ij_mag << " , " + << ComputePairPotentialDerivative(r_ij_mag) << " , " + << dfrho_e << std::endl; exit(0); } } diff --git a/src/materials/copper/copperTabulated.h b/src/materials/copper/copperTabulated.h index 9ce8fab02..0c13d2edd 100644 --- a/src/materials/copper/copperTabulated.h +++ b/src/materials/copper/copperTabulated.h @@ -18,16 +18,16 @@ class SetflCopperEAM : public SetflTabulatedEAM<DIM> { double densityFunctionInputMin_; double densityFunctionInputMax_; - string Name_; + std::string Name_; public: typedef SetflTabulatedEAM<DIM> Base; - typedef array<double, DIM> point; - typedef array<double, NIDOF> thermalPoint; + typedef std::array<double, DIM> point; + typedef std::array<double, NIDOF> thermalPoint; typedef Eigen::Matrix<double, DIM, DIM> matrix; - SetflCopperEAM(const string filename) : Base(filename) { + SetflCopperEAM(const std::string filename) : Base(filename) { const TabulatedEmbeddedAtomInformation info = Base::getTabulatedEmbeddedAtomInformation(); @@ -50,15 +50,15 @@ public: densityFunctionInputMax_ = densityFunctionInterpolator_.getDomainMax(); } - void setName(const string &_name) { Name_ = _name; } + void setName(const std::string &_name) { Name_ = _name; } bool GetEAMFlag() { return true; } - array<double, DIM> getCellDimensions() const { + std::array<double, DIM> getCellDimensions() const { double sideLength = Base::getcellSideLength(); if (DIM == 2) { - array<double, DIM> returnVal; + std::array<double, DIM> returnVal; // this is the energy minimum for this potential, // obtained using the LatticeSpacing executable // returnVal[0] = 2.475547477961683285; @@ -66,20 +66,20 @@ public: returnVal[1] = sin(PI / 3.) * 2.0 * returnVal[0]; return returnVal; } else if (DIM == 3) { - array<double, DIM> returnVal; + std::array<double, DIM> returnVal; returnVal[0] = sideLength; returnVal[1] = returnVal[0]; returnVal[2] = returnVal[0]; return returnVal; } else { - cout << "invalid spatial dimension. Should be 2 or 3, but got " << DIM - << endl; + std::cout << "invalid spatial dimension. Should be 2 or 3, but got " + << DIM << std::endl; exit(0); } } void AssignBasisVectors(const matrix _M) { - array<double, DIM> UnitCell = this->getCellDimensions(); + std::array<double, DIM> UnitCell = this->getCellDimensions(); if (DIM == 2) { this->BasisVectors[0][0] = UnitCell[0]; @@ -89,7 +89,7 @@ public: this->BasisVectors[1][1] = sin(PI / 3.0) * UnitCell[0]; } else if (DIM == 3) { - array<double, DIM * DIM> basis; + std::array<double, DIM * DIM> basis; basis[0] = UnitCell[0] / 2.0; basis[1] = UnitCell[0] / 2.0; @@ -104,7 +104,7 @@ public: matrix basis_prime = Eigen::Map<matrix>(basis.data(), DIM, DIM).transpose() * _M; if (mpi_rank == 0) { - cout << Eigen::Map<matrix>(basis.data(), DIM, DIM) << endl; + std::cout << Eigen::Map<matrix>(basis.data(), DIM, DIM) << std::endl; } for (int i = 0; i < DIM; i++) { @@ -116,8 +116,8 @@ public: } void getCentrosymmetryNeighbourhood(const bool &_constrained, - vector<point> &_centroSymmetries) { - array<double, DIM> UnitCell = this->getCellDimensions(); + std::vector<point> &_centroSymmetries) { + std::array<double, DIM> UnitCell = this->getCellDimensions(); _centroSymmetries.clear(); const double a = UnitCell[0] / 2.0; @@ -148,9 +148,9 @@ public: double getAtomicMass() { return 63.546; } - string getMaterialName() { return Name_; } + std::string getMaterialName() { return Name_; } - string getLatticeStructureName() { + std::string getLatticeStructureName() { return GET_VARIABLE_NAME(getLatticeStructure()); } @@ -208,7 +208,7 @@ public: } void getClusterEnergy(double &_U, const point &_atom, - const vector<point> &_neighbours) { + const std::vector<point> &_neighbours) { _U = 0.0; double rho_e, f_rho_e, phi_ij, r_ij_mag; @@ -230,8 +230,8 @@ public: } } - void getClusterForces(vector<point> &_forces, const point &_atom, - const vector<point> &_neighbours) { + void getClusterForces(std::vector<point> &_forces, const point &_atom, + const std::vector<point> &_neighbours) { _forces.clear(); _forces.reserve(_neighbours.size()); @@ -262,8 +262,8 @@ public: void getThermalizedEnergy_3( double &_U, const point &_atom, const thermalPoint &_atomThermalCoordinates, - const vector<point> &_neighbours, - const vector<thermalPoint> &_neighboursThermalCoordinates) { + const std::vector<point> &_neighbours, + const std::vector<thermalPoint> &_neighboursThermalCoordinates) { _U = 0.0; int noof_neighbours, noof_scalars, noof_quadrature_samples, @@ -273,7 +273,7 @@ public: point r_ij, quad_point, sampling_atom_shift, neighbour_shift; - vector<point> neighbour_shifts; + std::vector<point> neighbour_shifts; neighbour_shifts.reserve(200); noof_neighbours = _neighbours.size(); @@ -315,11 +315,12 @@ public: sampling_atom_shift + _atom); if (std::isnan(r_ij_mag)) { - cout << "nan distance detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << endl; + std::cout << "nan distance detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << std::endl; exit(0); } @@ -342,12 +343,13 @@ public: _U += w_quad * phi_ij; if (std::isnan(_U)) { - cout << "nan poitential detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << " , " << r_ij_mag << " , " - << phi_ij << " , " << f_rho_e << endl; + std::cout << "nan poitential detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << " , " << r_ij_mag << " , " << phi_ij << " , " << f_rho_e + << std::endl; exit(0); } } @@ -355,16 +357,17 @@ public: } void getThermalizedForces_3( - vector<point> &_forces, vector<double> &_thermal_forces_sampling_atom, - vector<double> &_thermal_forces_neighbours, const point &_atom, + std::vector<point> &_forces, + std::vector<double> &_thermal_forces_sampling_atom, + std::vector<double> &_thermal_forces_neighbours, const point &_atom, const thermalPoint &_atomThermalCoordinates, - const vector<point> &_neighbours, - const vector<thermalPoint> &_neighboursThermalCoordinates) { + const std::vector<point> &_neighbours, + const std::vector<thermalPoint> &_neighboursThermalCoordinates) { _forces.clear(); _thermal_forces_sampling_atom.clear(); _thermal_forces_neighbours.clear(); - _forces.resize(_neighbours.size(), filled_array<point>(0.0)); + _forces.resize(_neighbours.size(), std::filled_array<point>(0.0)); _thermal_forces_sampling_atom.resize(_neighbours.size(), 0.0); _thermal_forces_neighbours.resize(_neighbours.size(), 0.0); @@ -377,7 +380,7 @@ public: point f_ij, r_ij, quad_point, sampling_atom_shift, neighbour_shift; - vector<point> neighbour_shifts; + std::vector<point> neighbour_shifts; neighbour_shifts.reserve(200); noof_neighbours = _neighbours.size(); @@ -419,11 +422,12 @@ public: sampling_atom_shift + _atom); if (std::isnan(r_ij_mag)) { - cout << "nan distance detected " - << " , " << _neighboursThermalCoordinates[neighbourIdx] << " , " - << neighbour_shift << " , " << _neighbours[neighbourIdx] << " , " - << sampling_atom_shift << " , " << _atom << " , " - << _atomThermalCoordinates << endl; + std::cout << "nan distance detected " + << " , " << _neighboursThermalCoordinates[neighbourIdx] + << " , " << neighbour_shift << " , " + << _neighbours[neighbourIdx] << " , " << sampling_atom_shift + << " , " << _atom << " , " << _atomThermalCoordinates + << std::endl; exit(0); } @@ -456,4 +460,4 @@ public: } } } -}; \ No newline at end of file +}; diff --git a/src/materials/material.h b/src/materials/material.h index 63b74c404..c2ef80047 100644 --- a/src/materials/material.h +++ b/src/materials/material.h @@ -11,8 +11,6 @@ #include "utilities.h" #include "variables.h" -using namespace std; - enum LatticeStructure { SimpleCubic, BCC, FCC, HCP, None }; struct LennardJonesInformation { @@ -39,15 +37,15 @@ struct TabulatedEmbeddedAtomInformation { template <int DIM> class material { public: - array<array<double, DIM>, DIM> BasisVectors; - typedef array<double, DIM> point; - typedef array<double, NIDOF> thermalPoint; + std::array<std::array<double, DIM>, DIM> BasisVectors; + typedef std::array<double, DIM> point; + typedef std::array<double, NIDOF> thermalPoint; typedef Eigen::Matrix<double, DIM, DIM> matrix; double getMaterialDensity() { LatticeStructure latticeStructure = getLatticeStructure(); - array<double, DIM> cellDimensions = getCellDimensions(); + std::array<double, DIM> cellDimensions = getCellDimensions(); double cellVolume = cellDimensions[0]; for (int coordinate = 1; coordinate < DIM; ++coordinate) { @@ -66,21 +64,23 @@ public: return 2.0 / cellVolume; break; case HCP: - cout << "Cannot do hcp in 3D. See materials/materials.h and the " - "driver. Exiting..." - << endl; + std::cout << "Cannot do hcp in 3D. See materials/materials.h and the " + "driver. Exiting..." + << std::endl; exit(0); break; case None: - cout << "Lattice structure not defined. See materials/materials.h and " - "the driver. Exiting..." - << endl; + std::cout + << "Lattice structure not defined. See materials/materials.h and " + "the driver. Exiting..." + << std::endl; exit(0); break; default: - cout << "Unrecognized structure. See materials/materials.h and the " - "driver. Exiting..." - << endl; + std::cout + << "Unrecognized structure. See materials/materials.h and the " + "driver. Exiting..." + << std::endl; exit(0); break; } @@ -93,32 +93,34 @@ public: return 2.0 / cellVolume; break; case FCC: - cout << "Cannot do fcc in 2d. See materials/materials.h and the " - "driver. Exiting..." - << endl; + std::cout << "Cannot do fcc in 2d. See materials/materials.h and the " + "driver. Exiting..." + << std::endl; exit(0); break; case BCC: - cout << "Cannot do bcc in 2d. See materials/materials.h and the " - "driver. Exiting..." - << endl; + std::cout << "Cannot do bcc in 2d. See materials/materials.h and the " + "driver. Exiting..." + << std::endl; exit(0); break; case None: - cout << "Lattice structure not defined. See materials/materials.h and " - "the driver. Exiting..." - << endl; + std::cout + << "Lattice structure not defined. See materials/materials.h and " + "the driver. Exiting..." + << std::endl; exit(0); break; default: - cout << "Unrecognized structure. See materials/materials.h and the " - "driver. Exiting..." - << endl; + std::cout + << "Unrecognized structure. See materials/materials.h and the " + "driver. Exiting..." + << std::endl; exit(0); break; } } else { - cout << "DIM Unrecognized. Exiting...." << endl; + std::cout << "DIM Unrecognized. Exiting...." << std::endl; exit(0); } } @@ -131,21 +133,21 @@ public: virtual void getCentrosymmetryNeighbourhood(const bool &, - vector<point> &_centroSymmetries) = 0; + std::vector<point> &_centroSymmetries) = 0; - virtual void setName(const string &) = 0; + virtual void setName(const std::string &) = 0; - virtual string getMaterialName() = 0; + virtual std::string getMaterialName() = 0; // this way of virtual function declaration requires derived classes // to define it - virtual string getLatticeStructureName() = 0; + virtual std::string getLatticeStructureName() = 0; virtual double getNeighborInteractionCutoffRadius() = 0; virtual LatticeStructure getLatticeStructure() = 0; - virtual array<double, DIM> getCellDimensions() const = 0; + virtual std::array<double, DIM> getCellDimensions() const = 0; virtual double getAtomicMass() = 0; @@ -166,21 +168,22 @@ public: virtual bool GetEAMFlag() = 0; virtual void getClusterEnergy(double &, const point &, - const vector<point> &) = 0; + const std::vector<point> &) = 0; virtual void getThermalizedEnergy_3(double &, const point &, const thermalPoint &, - const vector<point> &, - const vector<thermalPoint> &) = 0; + const std::vector<point> &, + const std::vector<thermalPoint> &) = 0; - virtual void getClusterForces(vector<point> &, const point &, - const vector<point> &) = 0; + virtual void getClusterForces(std::vector<point> &, const point &, + const std::vector<point> &) = 0; - virtual void getThermalizedForces_3(vector<point> &, vector<double> &, - vector<double> &, const point &, + virtual void getThermalizedForces_3(std::vector<point> &, + std::vector<double> &, + std::vector<double> &, const point &, const thermalPoint &, - const vector<point> &, - const vector<thermalPoint> &) = 0; + const std::vector<point> &, + const std::vector<thermalPoint> &) = 0; }; // file parsing taken from Jeff's Materials.h @@ -192,26 +195,26 @@ template <int DIM> class SetflTabulatedEAM : public material<DIM> { double cellSideLength_; double atomicMass_; TabulatedEmbeddedAtomInformation tabulatedEmbeddedAtomInformation_; - string materialName_; + std::string materialName_; public: - typedef array<double, DIM> point; - typedef array<double, NIDOF> thermalPoint; + typedef std::array<double, DIM> point; + typedef std::array<double, NIDOF> thermalPoint; typedef Eigen::Matrix<double, DIM, DIM> matrix; public: - string getMaterialName() const { return materialName_; } + std::string getMaterialName() const { return materialName_; } - SetflTabulatedEAM(const string filename) { + SetflTabulatedEAM(const std::string filename) { // parse file, populate data structures std::ifstream file(filename.c_str()); assert(file.is_open()); - string line; + std::string line; // skip the first three lines getline(file, line); - std::array<string, 3> lines; + std::array<std::string, 3> lines; lines[0] = line; getline(file, line); lines[1] = line; @@ -220,11 +223,11 @@ public: char buffer[10000]; sprintf(buffer, "%s %s %s", lines[0].c_str(), lines[1].c_str(), lines[2].c_str()); - materialName_ = string(buffer); + materialName_ = std::string(buffer); // make sure there's only 1 element getline(file, line); - vector<string> tokens; + std::vector<std::string> tokens; tokenize(line, " ", FileUtilities::Trim, &tokens); assert(tokens.size() != 0); @@ -262,7 +265,7 @@ public: // read the cell side length cellSideLength_ = FileUtilities::convertString<double>(tokens[2]); // extract the lattice structure type from the string - string latticeStructureString = tokens[3]; + std::string latticeStructureString = tokens[3]; // convert to lower case std::transform(latticeStructureString.begin(), latticeStructureString.end(), latticeStructureString.begin(), ::tolower); @@ -279,14 +282,14 @@ public: } // parse all of the numbers into storage; - vector<double> numbers; + std::vector<double> numbers; numbers.reserve(numberOfEmbeddingEntries + 2 * numberOfDensityAndPotentialEntries); while (getline(file, line)) { tokens.resize(0); tokenize(line, " ", FileUtilities::Trim, &tokens); - for (const string token : tokens) { + for (const std::string token : tokens) { numbers.push_back(FileUtilities::convertString<double>(token)); } } @@ -342,24 +345,25 @@ public: double getAtomicMass() const { return atomicMass_; } double getcellSideLength() const { return cellSideLength_; } - virtual void setName(const string &) = 0; + virtual void setName(const std::string &) = 0; virtual void AssignBasisVectors(const matrix M) = 0; virtual void getClusterEnergy(double &, const point &, - const vector<point> &) = 0; + const std::vector<point> &) = 0; virtual void getThermalizedEnergy_3(double &, const point &, const thermalPoint &, - const vector<point> &, - const vector<thermalPoint> &) = 0; + const std::vector<point> &, + const std::vector<thermalPoint> &) = 0; - virtual void getClusterForces(vector<point> &, const point &, - const vector<point> &) = 0; + virtual void getClusterForces(std::vector<point> &, const point &, + const std::vector<point> &) = 0; - virtual void getThermalizedForces_3(vector<point> &, vector<double> &, - vector<double> &, const point &, + virtual void getThermalizedForces_3(std::vector<point> &, + std::vector<double> &, + std::vector<double> &, const point &, const thermalPoint &, - const vector<point> &, - const vector<thermalPoint> &) = 0; + const std::vector<point> &, + const std::vector<thermalPoint> &) = 0; }; diff --git a/src/mesh/checkMeshTopologyAndConnectivity.ipp b/src/mesh/checkMeshTopologyAndConnectivity.ipp index a68e1967d..85013d9f0 100644 --- a/src/mesh/checkMeshTopologyAndConnectivity.ipp +++ b/src/mesh/checkMeshTopologyAndConnectivity.ipp @@ -6,6 +6,7 @@ \author P. Gupta */ #pragma once +#include "qcMesh.h" namespace meshing { template <int D, int K> void KSimplexDMesh<D, K>::checkLocalFaceNeighbours() { @@ -14,8 +15,8 @@ template <int D, int K> void KSimplexDMesh<D, K>::checkLocalFaceNeighbours() { _pairKey_ neighbourKey; int localNeighbourMirrorIndex; - vector<size_t> nodeKeysCell(K); - vector<size_t> nodeKeysNeighbour(K); + std::vector<size_t> nodeKeysCell(K); + std::vector<size_t> nodeKeysNeighbour(K); bool checksOut = true; @@ -68,4 +69,4 @@ template <int D, int K> void KSimplexDMesh<D, K>::checkLocalFaceNeighbours() { << endl; } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/element_tessellators.h b/src/mesh/element_tessellators.h index a885f1ec2..35b7957ea 100644 --- a/src/mesh/element_tessellators.h +++ b/src/mesh/element_tessellators.h @@ -394,4 +394,4 @@ void tessellateElementPlanes( } } // namespace tessellators -#endif \ No newline at end of file +#endif diff --git a/src/mesh/gatherHaloMesh.ipp b/src/mesh/gatherHaloMesh.ipp index 6a6177410..d2e441ba9 100644 --- a/src/mesh/gatherHaloMesh.ipp +++ b/src/mesh/gatherHaloMesh.ipp @@ -1,5 +1,5 @@ - #pragma once +#include "qcMesh.h" namespace meshing { template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloCells() { @@ -46,9 +46,9 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloCells() { } // int data has simplex keys followed by K+1 node keys - vector<vector<unsigned int>> intDataSend(mpi_size); + std::vector<std::vector<unsigned int>> intDataSend(mpi_size); - vector<unsigned int> noofCellsSend(mpi_size, 0); + std::vector<unsigned int> noofCellsSend(mpi_size, 0); // halo_node_keys_sent_ marks the already sent keys for (int rank = 0; rank < mpi_size; rank++) { @@ -74,12 +74,12 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloCells() { } // exchange the halo noof halo mesh nodes - vector<unsigned int> noofCellsRecv(mpi_size); + std::vector<unsigned int> noofCellsRecv(mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<unsigned int>( noofCellsSend, noofCellsRecv, mpi_size); - vector<vector<unsigned int>> intDataRecv(mpi_size); + std::vector<std::vector<unsigned int>> intDataRecv(mpi_size); for (int rank = 0; rank < mpi_size; rank++) { intDataRecv[rank].resize((K + 2) * noofCellsRecv[rank]); @@ -93,7 +93,7 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloCells() { _simplexCell_ cell; - unordered_map<size_t, _pairKey_> addedNodesFromRecv; + std::unordered_map<size_t, _pairKey_> addedNodesFromRecv; for (int rank = 0; rank < mpi_size; rank++) { if (intDataRecv[rank].size() > 0 && rank != mpi_rank) { @@ -106,7 +106,7 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloCells() { cellKey = intDataRecv[rank][int_data_ctr]; ++int_data_ctr; - cell.setPairKey(make_pair(rank, cellKey)); + cell.setPairKey(std::make_pair(rank, cellKey)); for (int d = 0; d < K + 1; d++) { // node key to be added @@ -119,20 +119,20 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloCells() { // previous rank if (addedNodesFromRecv.find(nodeKey) == addedNodesFromRecv.end()) { // this node is unique, not sent by other rank also - cell.setNode(make_pair(rank, nodeKey), d); + cell.setNode(std::make_pair(rank, nodeKey), d); // mark this as added addedNodesFromRecv.insert( - make_pair(nodeKey, make_pair(rank, nodeKey))); + std::make_pair(nodeKey, std::make_pair(rank, nodeKey))); } else { cell.setNode(addedNodesFromRecv.at(nodeKey), d); } } else { - cell.setNode(make_pair(mpi_rank, nodeKey), d); + cell.setNode(std::make_pair(mpi_rank, nodeKey), d); } } - halo_mesh_simplices_.insert(make_pair(cellKey, cell)); + halo_mesh_simplices_.insert(std::make_pair(cellKey, cell)); } assert(int_data_ctr == cell_data_offset); @@ -191,7 +191,7 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { #ifdef DISPLAY_HALO_MESH sending_ranks_cells_.insert( - make_pair(adj_simplex_key.second, connected_rank)); + std::make_pair(adj_simplex_key.second, connected_rank)); #endif // } @@ -200,14 +200,14 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { } // int data has simplex keys followed by K+1 node keys - vector<vector<unsigned int>> intDataSend(mpi_size); + std::vector<std::vector<unsigned int>> intDataSend(mpi_size); - vector<unsigned int> nodeIntDataSend; + std::vector<unsigned int> nodeIntDataSend; // double data is just the coordinate values - vector<vector<double>> coordinatesSend(mpi_size); + std::vector<std::vector<double>> coordinatesSend(mpi_size); - vector<unsigned int> noofCellsSend(mpi_size, 0); - vector<unsigned int> noofNodesSend(mpi_size, 0); + std::vector<unsigned int> noofCellsSend(mpi_size, 0); + std::vector<unsigned int> noofNodesSend(mpi_size, 0); nodeIntDataSend.reserve(meshNodes_.size()); @@ -256,11 +256,11 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { } // release any memory - vector<unsigned int>().swap(nodeIntDataSend); + std::vector<unsigned int>().swap(nodeIntDataSend); // exchange the noof halo mesh cells and nodes - vector<unsigned int> noofCellsRecv(mpi_size); - vector<unsigned int> noofNodesRecv(mpi_size); + std::vector<unsigned int> noofCellsRecv(mpi_size); + std::vector<unsigned int> noofNodesRecv(mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<unsigned int>( noofCellsSend, noofCellsRecv, mpi_size); @@ -268,8 +268,8 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { mpi_utilities::MPIExchangeBuffers_NonBlocking<unsigned int>( noofNodesSend, noofNodesRecv, mpi_size); - vector<vector<unsigned int>> intDataRecv(mpi_size); - vector<vector<double>> coordinatesRecv(mpi_size); + std::vector<std::vector<unsigned int>> intDataRecv(mpi_size); + std::vector<std::vector<double>> coordinatesRecv(mpi_size); for (int rank = 0; rank < mpi_size; rank++) { intDataRecv[rank].resize((K + 2) * noofCellsRecv[rank] + @@ -304,7 +304,7 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { cellKey = intDataRecv[rank][int_data_ctr]; ++int_data_ctr; - cell.setPairKey(make_pair(rank, cellKey)); + cell.setPairKey(std::make_pair(rank, cellKey)); for (int d = 0; d < K + 1; d++) { // node key to be added @@ -317,18 +317,18 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { // previous rank if (halo_mesh_nodes_.find(nodeKey) == halo_mesh_nodes_.end()) { // this node is unique, not sent by other rank also - cell.setNode(make_pair(rank, nodeKey), d); + cell.setNode(std::make_pair(rank, nodeKey), d); // we will add this node and its coordinates later on } else { cell.setNode(halo_mesh_nodes_.at(nodeKey).getPairKey(), d); } } else { - cell.setNode(make_pair(mpi_rank, nodeKey), d); + cell.setNode(std::make_pair(mpi_rank, nodeKey), d); } } - halo_mesh_simplices_.insert(make_pair(cellKey, cell)); + halo_mesh_simplices_.insert(std::make_pair(cellKey, cell)); } assert(int_data_ctr == cell_data_offset); @@ -339,7 +339,7 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { if (meshNodes_.find(nodeKey) == meshNodes_.end() && halo_mesh_nodes_.find(nodeKey) == halo_mesh_nodes_.end()) { // this node is not in meshnodes or halo nodes. add it - node.setPairKey(make_pair(rank, nodeKey)); + node.setPairKey(std::make_pair(rank, nodeKey)); for (int d = 0; d < D; d++) { point[d] = coordinatesRecv[rank][coord_data_ctr]; @@ -347,7 +347,7 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::gatherHaloMesh() { } node.setPoint(point); - halo_mesh_nodes_.insert(make_pair(nodeKey, node)); + halo_mesh_nodes_.insert(std::make_pair(nodeKey, node)); } else { coord_data_ctr += D; } @@ -360,7 +360,7 @@ template <int D, int K, int NIDOF, typename repatomContainer, typename samplingAtomContainer> inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: - gatherRequiredHaloMesh(const vector<size_t> &_elementIds) { + gatherRequiredHaloMesh(const std::vector<size_t> &_elementIds) { // only required halo cells are communicated. // clear out previous data Base::halo_mesh_simplices_.clear(); @@ -379,8 +379,8 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: Base::buildNodeCellAdjacency(); // all gather node keys that would require halo elements - unordered_set<size_t> addedKeys; - vector<size_t> nodesRequiringHalo; + std::unordered_set<size_t> addedKeys; + std::vector<size_t> nodesRequiringHalo; nodesRequiringHalo.reserve(Base::meshNodes_.size()); @@ -398,7 +398,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: } nodesRequiringHalo.shrink_to_fit(); - vector<int> noofNodesForHaloMeshAllProc(mpi_size, 0); + std::vector<int> noofNodesForHaloMeshAllProc(mpi_size, 0); // all-gather number of nodes requiring halo mesh @@ -406,7 +406,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: noofNodesForHaloMeshAllProc, 1); // first compute the displacements from _N - vector<int> displacements(mpi_size, 0); + std::vector<int> displacements(mpi_size, 0); for (int i_rank = 1; i_rank != mpi_size; ++i_rank) { displacements[i_rank] = displacements[i_rank - 1] + noofNodesForHaloMeshAllProc[i_rank - 1]; @@ -415,7 +415,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: size_t totalNodesForHalo = displacements[mpi_size - 1] + noofNodesForHaloMeshAllProc[mpi_size - 1]; - vector<size_t> nodesRequiringHaloAllProcs(totalNodesForHalo); + std::vector<size_t> nodesRequiringHaloAllProcs(totalNodesForHalo); mpi_utilities::ALLGATHERV<size_t>(nodesRequiringHalo, nodesRequiringHaloAllProcs, @@ -426,7 +426,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: noofNodesForHaloMeshAllProc[mpi_size - 1]); // set<size_t> uniqueHaloNodesAllProc_set; - // vector<vector<int>> ranksOfUniqueHaloNodes; + // std::vector<std::vector<int>> ranksOfUniqueHaloNodes; int nodeRank; size_t nodeIndex, cellIndex; @@ -435,7 +435,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // { // nodeKey = nodesRequiringHaloAllProcs[nodeCtr]; - // const vector<int>::const_iterator it = + // const std::vector<int>::const_iterator it = // upper_bound(displacements.cbegin(), // displacements.cend(), nodeCtr); @@ -443,7 +443,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // if(uniqueHaloNodesAllProc_set.find(nodeKey)==uniqueHaloNodesAllProc_set.end()) // { - // ranksOfUniqueHaloNodes.push_back(vector<int>{nodeRank}); + // ranksOfUniqueHaloNodes.push_back(std::vector<int>{nodeRank}); // uniqueHaloNodesAllProc_set.insert(nodeKey); // } // else @@ -455,14 +455,14 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // } // } - // vector<size_t> uniqueHaloNodesAllProc(uniqueHaloNodesAllProc_set.begin(), + // std::vector<size_t> uniqueHaloNodesAllProc(uniqueHaloNodesAllProc_set.begin(), // uniqueHaloNodesAllProc_set.end()); // set<size_t>().swap(uniqueHaloNodesAllProc_set); - unordered_map<size_t, vector<int>> ranksOfUniqueHaloNodes; + std::unordered_map<size_t, std::vector<int>> ranksOfUniqueHaloNodes; - vector<unordered_set<size_t>> addedSimplicesToSend(mpi_size); - vector<unordered_set<size_t>> addedNodesToSend(mpi_size); + std::vector<std::unordered_set<size_t>> addedSimplicesToSend(mpi_size); + std::vector<std::unordered_set<size_t>> addedNodesToSend(mpi_size); size_t noof_incident, adj_simplex_key; @@ -470,13 +470,14 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: for (size_t nodeCtr = 0; nodeCtr < nodesRequiringHaloAllProcs.size(); nodeCtr++) { nodeKey = nodesRequiringHaloAllProcs[nodeCtr]; - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(displacements.cbegin(), displacements.cend(), nodeCtr); nodeRank = distance(displacements.cbegin(), it) - 1; if (ranksOfUniqueHaloNodes.find(nodeKey) == ranksOfUniqueHaloNodes.end()) { - ranksOfUniqueHaloNodes.insert(make_pair(nodeKey, vector<int>{})); + ranksOfUniqueHaloNodes.insert( + std::make_pair(nodeKey, std::vector<int>{})); } ranksOfUniqueHaloNodes.at(nodeKey).push_back(nodeRank); @@ -521,14 +522,14 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: int nVarInt = 1; // prepare send data from addedSimplicesToSend - vector<vector<size_t>> intDataSend(mpi_size); - vector<vector<double>> doubleDataSend(mpi_size); + std::vector<std::vector<size_t>> intDataSend(mpi_size); + std::vector<std::vector<double>> doubleDataSend(mpi_size); - vector<size_t> nodeIntDataSend; - vector<double> nodeDoubleDataSend; + std::vector<size_t> nodeIntDataSend; + std::vector<double> nodeDoubleDataSend; - vector<int> noofCellsSend(mpi_size, 0); - vector<int> noofNodesSend(mpi_size, 0); + std::vector<int> noofCellsSend(mpi_size, 0); + std::vector<int> noofNodesSend(mpi_size, 0); // int data for nodes is material_idx and key nodeIntDataSend.reserve((1 + nVarInt) * Base::meshNodes_.size()); @@ -609,19 +610,19 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: } // exchange these - vector<double>().swap(nodeDoubleDataSend); - vector<size_t>().swap(nodeIntDataSend); + std::vector<double>().swap(nodeDoubleDataSend); + std::vector<size_t>().swap(nodeIntDataSend); - vector<int> noofCellsRecv(mpi_size, 0); - vector<int> noofNodesRecv(mpi_size, 0); + std::vector<int> noofCellsRecv(mpi_size, 0); + std::vector<int> noofNodesRecv(mpi_size, 0); mpi_utilities::MPIExchangeBuffers_NonBlocking<int>(noofCellsSend, noofCellsRecv, mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<int>(noofNodesSend, noofNodesRecv, mpi_size); - vector<vector<double>> doubleDataRecv(mpi_size); - vector<vector<size_t>> intDataRecv(mpi_size); + std::vector<std::vector<double>> doubleDataRecv(mpi_size); + std::vector<std::vector<size_t>> intDataRecv(mpi_size); for (int rank = 0; rank < mpi_size; ++rank) { doubleDataRecv[rank].resize((D * D) * noofCellsRecv[rank] + @@ -683,8 +684,8 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: cellKey = intDataRecv[rank][intDataCtr]; ++intDataCtr; - haloCellsBasis_.insert(make_pair(cellKey, recv_matrix)); - recv_cell.setPairKey(make_pair(rank, cellKey)); + haloCellsBasis_.insert(std::make_pair(cellKey, recv_matrix)); + recv_cell.setPairKey(std::make_pair(rank, cellKey)); for (int d = 0; d < K + 1; d++) { // node key to be added @@ -698,7 +699,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: if (Base::halo_mesh_nodes_.find(nodeKey) == Base::halo_mesh_nodes_.end()) { // this node is unique, not sent by other rank also - recv_cell.setNode(make_pair(rank, nodeKey), d); + recv_cell.setNode(std::make_pair(rank, nodeKey), d); // we will add this node and its coordinates later on } else { @@ -706,11 +707,11 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: d); } } else { - recv_cell.setNode(make_pair(mpi_rank, nodeKey), d); + recv_cell.setNode(std::make_pair(mpi_rank, nodeKey), d); } } - Base::halo_mesh_simplices_.insert(make_pair(cellKey, recv_cell)); + Base::halo_mesh_simplices_.insert(std::make_pair(cellKey, recv_cell)); } assert(intDataCtr == cellIntDataOffset); @@ -726,7 +727,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: if (Base::meshNodes_.find(nodeKey) == Base::meshNodes_.end() && Base::halo_mesh_nodes_.find(nodeKey) == Base::halo_mesh_nodes_.end()) { - recv_node.setPairKey(make_pair(rank, nodeKey)); + recv_node.setPairKey(std::make_pair(rank, nodeKey)); for (int d = 0; d < D; d++) { recv_point[d] = doubleDataRecv[rank][doubleDataCtr]; @@ -734,10 +735,10 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: } recv_node.setPoint(recv_point); - Base::halo_mesh_nodes_.insert(make_pair(nodeKey, recv_node)); + Base::halo_mesh_nodes_.insert(std::make_pair(nodeKey, recv_node)); haloNodeMaterialIndices_.insert( - make_pair(nodeKey, nodeMaterialIndex)); + std::make_pair(nodeKey, nodeMaterialIndex)); #ifdef FINITE_TEMPERATURE for (int d = 0; d < NIDOF; d++) { @@ -745,12 +746,13 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: doubleDataCtr++; } - haloNodeThermalPoints_.insert(make_pair(nodeKey, recv_thermal_point)); + haloNodeThermalPoints_.insert( + std::make_pair(nodeKey, recv_thermal_point)); recv_entropy = doubleDataRecv[rank][doubleDataCtr]; doubleDataCtr++; - haloNodeEntropy_.insert(make_pair(nodeKey, recv_entropy)); + haloNodeEntropy_.insert(std::make_pair(nodeKey, recv_entropy)); #endif } else { doubleDataCtr += D; diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index a5f76f566..5453b3efd 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -35,9 +35,6 @@ #include <boost/optional.hpp> -using namespace std; -using namespace geometry; - namespace meshing { //! Generic mesh class. Stores nodes @@ -63,23 +60,23 @@ public: public: typedef point<D> _node_; - typedef array<_node_, K + 1> _simplex_; - typedef array<size_t, K + 1> _ind_simplex_; - typedef array<size_t, K> _vidx_face_; - typedef pair<int, size_t> _pairKey_; - typedef array<_pairKey_, K> _vkeyFace_; + typedef std::array<_node_, K + 1> _simplex_; + typedef std::array<size_t, K + 1> _ind_simplex_; + typedef std::array<size_t, K> _vidx_face_; + typedef std::pair<int, size_t> _pairKey_; + typedef std::array<_pairKey_, K> _vkeyFace_; typedef simplexCell<D, K> _simplexCell_; typedef node<D> _simplexNode_; // typedef typename vector<_ind_simplex_>::iterator _index_simplex_iterator_; - typedef typename unordered_map<size_t, _ind_simplex_>::iterator + typedef typename std::unordered_map<size_t, _ind_simplex_>::iterator _index_simplex_iterator_; - typedef - typename unordered_map<size_t, _simplexCell_>::iterator _cell_iterator_; + typedef typename std::unordered_map<size_t, _simplexCell_>::iterator + _cell_iterator_; - typedef Triplet<_pairKey_, int, int> _edge_; - typedef pair<_pairKey_, int> _face_; - typedef Triplet<int, size_t, _node_> _periodicNodeImage_; + typedef std::Triplet<_pairKey_, int, int> _edge_; + typedef std::pair<_pairKey_, int> _face_; + typedef std::Triplet<int, size_t, _node_> _periodicNodeImage_; // geometry variables added later on by Manuel for face removal // typedef Face<_pairKey_, size_t> _geomFace_; @@ -102,22 +99,22 @@ public: public: // REMOVE // geometric information of nodes - vector<_node_> nodes_; + std::vector<_node_> nodes_; // REMOVE - unordered_map<size_t, _ind_simplex_> simplices_; + std::unordered_map<size_t, _ind_simplex_> simplices_; // KEEP - unordered_map<size_t, _simplexCell_> meshCells_; - unordered_map<size_t, _simplexNode_> meshNodes_; + std::unordered_map<size_t, _simplexCell_> meshCells_; + std::unordered_map<size_t, _simplexNode_> meshNodes_; // REMOVE - vector<_face_> faces_; - vector<bool> if_boundary_faces_; + std::vector<_face_> faces_; + std::vector<bool> if_boundary_faces_; // KEEP - vector<_pairKey_> vertex_adj_; - vector<vector<_pairKey_>::iterator> vertex_adj_pointers_; + std::vector<_pairKey_> vertex_adj_; + std::vector<std::vector<_pairKey_>::iterator> vertex_adj_pointers_; // KEEP size_t newCellKey_; // this is unique w.r.t keys local to the rank @@ -125,41 +122,42 @@ public: public: // mark if this element was already sent - vector<unordered_set<size_t>> halo_simplex_keys_sent_; - vector<unordered_set<size_t>> halo_node_keys_sent_; + std::vector<std::unordered_set<size_t>> halo_simplex_keys_sent_; + std::vector<std::unordered_set<size_t>> halo_node_keys_sent_; - unordered_map<size_t, _simplexCell_> halo_mesh_simplices_; - unordered_map<size_t, _simplexNode_> halo_mesh_nodes_; + std::unordered_map<size_t, _simplexCell_> halo_mesh_simplices_; + std::unordered_map<size_t, _simplexNode_> halo_mesh_nodes_; #ifdef DISPLAY_HALO_MESH - unordered_map<size_t, int> sending_ranks_cells_; + std::unordered_map<size_t, int> sending_ranks_cells_; #endif #ifdef DISPLAY_ATOM_MARKERS - vector<int> ghost_nodes_; + std::vector<int> ghost_nodes_; #endif public: - vector<size_t> simplex_index_to_key_; - vector<size_t> node_index_to_key_; + std::vector<size_t> simplex_index_to_key_; + std::vector<size_t> node_index_to_key_; // connected nodes and faces (important for partitioned meshes) public: // indices in nodes - vector<int> connected_node_procs_; - vector<vector<size_t>> connected_nodes_; + std::vector<int> connected_node_procs_; + std::vector<std::vector<size_t>> connected_nodes_; - unordered_map<size_t, vector<_periodicNodeImage_>> nodePeriodicImages_; - unordered_map<size_t, size_t> originalKeysOfPeriodicImages_; - unordered_map<size_t, point<D>> offsetsOfPeriodicImages_; + std::unordered_map<size_t, std::vector<_periodicNodeImage_>> + nodePeriodicImages_; + std::unordered_map<size_t, size_t> originalKeysOfPeriodicImages_; + std::unordered_map<size_t, point<D>> offsetsOfPeriodicImages_; // how many copies of the nodes among all ranks. // allocated in renumbering of mesh according to PETSC - vector<int> node_multiplicities_; + std::vector<int> node_multiplicities_; size_t noof_ghosts_; - vector<int> globalGhostIndices_; - vector<_node_> ghostNodeOffsets_; + std::vector<int> globalGhostIndices_; + std::vector<_node_> ghostNodeOffsets_; Vec distributedNodalDataPetsc_, localNodaldataPetsc_; // for exchange of weights @@ -171,10 +169,10 @@ public: PetscScalar *localNodalMultiplicities_; public: - vector<size_t> deletedKeys_; + std::vector<size_t> deletedKeys_; #ifdef DISPLAY_BOUNDARY_NODES - vector<int> boundary_marker_; + std::vector<int> boundary_marker_; #endif public: @@ -186,8 +184,8 @@ public: } // ! assign nodes and simplices, and then build - KSimplexDMesh(const vector<_node_> &_nodes, - const vector<_ind_simplex_> &_elements) + KSimplexDMesh(const std::vector<_node_> &_nodes, + const std::vector<_ind_simplex_> &_elements) : nodes_(_nodes), simplices_(_elements), faces_(), if_boundary_faces_(), vertex_adj_(), vertex_adj_pointers_() { buildMeshTopology(); @@ -196,15 +194,15 @@ public: int computeOtherIndex(const int &i, const int &j, const int &k); - void build(const vector<_node_> &_nodes, - const vector<_ind_simplex_> &_elements) { + void build(const std::vector<_node_> &_nodes, + const std::vector<_ind_simplex_> &_elements) { // nodes_ = _nodes; // simplices_.reserve(_elements.size()); // for(size_t i_el=0; i_el<_elements.size(); i_el++) // { - // simplices_.insert(make_pair(i_el, _elements[i_el])); + // simplices_.insert(std::make_pair(i_el, _elements[i_el])); // } meshCells_.reserve(_elements.size()); @@ -215,12 +213,13 @@ public: for (size_t i_nd = 0; i_nd < _nodes.size(); i_nd++) { // indices and keys are same while building from vectors - meshNodes_.insert(make_pair(i_nd, node.setNode(_nodes[i_nd], i_nd))); + meshNodes_.insert(std::make_pair(i_nd, node.setNode(_nodes[i_nd], i_nd))); } for (size_t i_el = 0; i_el < _elements.size(); i_el++) { // indices and keys are same - meshCells_.insert(make_pair(i_el, cell.setCell(_elements[i_el], i_el))); + meshCells_.insert( + std::make_pair(i_el, cell.setCell(_elements[i_el], i_el))); } buildIndexKeyMaps(); @@ -230,7 +229,7 @@ public: } // This function does not set the nodal coordinates - void build(vector<int> _elements, vector<double> _nodes) { + void build(std::vector<int> _elements, std::vector<double> _nodes) { int elementSize = _elements.size(); int NodeSize = _nodes.size(); @@ -253,16 +252,16 @@ public: for (int element = 0; element < noofElements; element++) { int idFromArray = element * (K + 2); - array<size_t, K + 1> tmpElement; + std::array<size_t, K + 1> tmpElement; for (int i = 0; i < (K + 1); i++) { tmpElement[i] = _elements[idFromArray + 1 + i]; nodeKey = _elements[idFromArray + 1 + i]; if (meshNodes_.find(nodeKey) == meshNodes_.end()) { - node.setPairKey(make_pair(mpi_rank, nodeKey)); + node.setPairKey(std::make_pair(mpi_rank, nodeKey)); - meshNodes_.insert(make_pair(nodeKey, node)); + meshNodes_.insert(std::make_pair(nodeKey, node)); for (int d = 0; d < D; d++) { tmpPoint[d] = _nodes[element * (K + 1) * D + D * i + d]; @@ -273,21 +272,21 @@ public: } meshCells_.insert( - make_pair(_elements[idFromArray], - cell.setCell(tmpElement, _elements[idFromArray]))); + std::make_pair(_elements[idFromArray], + cell.setCell(tmpElement, _elements[idFromArray]))); } // for(size_t nodeCount = 0; nodeCount < noofNodes; nodeCount++) // { // int idFromArray = nodeCount*(D+1); // size_t nodeId = static_cast<size_t>(_nodes[idFromArray]); - // meshNodes_.insert(make_pair(nodeId, node.setNode(tmpPoint, nodeId))); + // meshNodes_.insert(std::make_pair(nodeId, node.setNode(tmpPoint, nodeId))); // } } template <typename MeshType> void uniformDistributionToLocalMesh(MeshType &_local_mesh, - const vector<int> &_materialIds); + const std::vector<int> &_materialIds); void buildSimplexIndexToKey() { simplex_index_to_key_.clear(); @@ -567,12 +566,14 @@ public: if (meshCells_.find(neighbourKey.second) != meshCells_.end()) { meshCells_.at(neighbourKey.second) - .setNeighbour(make_pair(-1, numeric_limits<size_t>::max()), nid); + .setNeighbour( + std::make_pair(-1, std::numeric_limits<size_t>::max()), nid); } else { assert(halo_mesh_simplices_.find(neighbourKey.second) != halo_mesh_simplices_.end()); halo_mesh_simplices_.at(neighbourKey.second) - .setNeighbour(make_pair(-1, numeric_limits<size_t>::max()), nid); + .setNeighbour( + std::make_pair(-1, std::numeric_limits<size_t>::max()), nid); } } } @@ -667,7 +668,7 @@ public: void insertCell(const _simplexCell_ &_cell) { - meshCells_.insert(make_pair(newCellKey_, _cell)); + meshCells_.insert(std::make_pair(newCellKey_, _cell)); // meshCells_.at(newCellKey_).setPairKey(make_pair(mpi_rank, newCellKey_)); // ++newCellKey_; @@ -686,7 +687,7 @@ public: // simplices_.insert(make_pair(returnKey, _new_simplex)); // face_adj_.insert(make_pair(returnKey, - // filled_array<array<size_t, K+1>> + // filled_std::array<std::array<size_t, K+1>> // (numeric_limits<size_t>::max()))); // return returnKey; @@ -694,7 +695,7 @@ public: template <typename inputIt, typename outputIt> void eraseCells(inputIt begin, inputIt end, outputIt output) { - vector<size_t> indicesToDelete; + std::vector<size_t> indicesToDelete; for (inputIt It = begin; It != end; ++It) { if (meshCells_.find((*It).second) != meshCells_.end()) { @@ -720,7 +721,7 @@ public: } template <typename inputIt> void eraseCellsMixed(inputIt begin, inputIt end) { - vector<size_t> indicesToDelete; + std::vector<size_t> indicesToDelete; for (inputIt It = begin; It != end; ++It) { if (meshCells_.find((*It).second) != meshCells_.end()) { @@ -780,10 +781,11 @@ public: } template <typename inputIt> - void getSimplicesFromCells(inputIt begin, inputIt end, - unordered_map<size_t, _ind_simplex_> &_simplices, - unordered_map<size_t, _node_> &_nodes, - unordered_map<size_t, int> &_ranks) { + void + getSimplicesFromCells(inputIt begin, inputIt end, + std::unordered_map<size_t, _ind_simplex_> &_simplices, + std::unordered_map<size_t, _node_> &_nodes, + std::unordered_map<size_t, int> &_ranks) { _simplices.reserve(distance(begin, end)); size_t nodeKey; @@ -794,14 +796,14 @@ public: nodeKey = getSimplexNodeKey(*begin, d); if (_nodes.find(nodeKey) == _nodes.end()) { - _nodes.insert(make_pair(nodeKey, getMeshPointFromKey(nodeKey))); + _nodes.insert(std::make_pair(nodeKey, getMeshPointFromKey(nodeKey))); } indexedSimplex[d] = nodeKey; } if (_ranks.find((*begin).second) == _ranks.end()) { - _simplices.insert(make_pair((*begin).second, indexedSimplex)); - _ranks.insert(make_pair((*begin).second, (*begin).first)); + _simplices.insert(std::make_pair((*begin).second, indexedSimplex)); + _ranks.insert(std::make_pair((*begin).second, (*begin).first)); } } } @@ -810,7 +812,7 @@ public: double getMaximumQualityResidual(inputIt begin, inputIt end) { double qr = 0.0; for (; begin != end; ++begin) { - qr = max(qr, simplexMetricResidual<K>(getSimplex(*begin))); + qr = std::max(qr, simplexMetricResidual<K>(getSimplex(*begin))); } return qr; @@ -835,7 +837,7 @@ public: } void getSimplexNodesSorted(const _pairKey_ &_simplex_key, - array<size_t, K + 1> &_nodes) { + std::array<size_t, K + 1> &_nodes) { if (meshCells_.find(_simplex_key.second) != meshCells_.end()) { for (int d = 0; d < K + 1; d++) _nodes[d] = meshCells_.at(_simplex_key.second)[d].second; @@ -885,7 +887,8 @@ public: template <typename OutputIterator> bool getIncidentCellsInOrder(const _edge_ &_edge, OutputIterator output, - vector<_node_> &_ring, vector<size_t> &_ringIDs); + std::vector<_node_> &_ring, + std::vector<size_t> &_ringIDs); // get only incident cells without any ring nodes template <typename OutputIterator> @@ -950,15 +953,15 @@ public: // ! local edge removal function template <typename edgeRemoval> bool tryEdgeRemoval(const _edge_ &, edgeRemoval &, - vector<_pairKey_> &_outputKeys, - unordered_map<size_t, _simplexCell_> &_outputCells); + std::vector<_pairKey_> &_outputKeys, + std::unordered_map<size_t, _simplexCell_> &_outputCells); // ! local edge removal function template <typename edgeRemoval> - bool - tryEdgeRemovalDependent(const int &, const _edge_ &, edgeRemoval &, - vector<_pairKey_> &_outputKeys, - unordered_map<size_t, _simplexCell_> &_outputCells); + bool tryEdgeRemovalDependent( + const int &, const _edge_ &, edgeRemoval &, + std::vector<_pairKey_> &_outputKeys, + std::unordered_map<size_t, _simplexCell_> &_outputCells); // ! comparator for priority queue from worst to best quality struct simplexQualityCompare { @@ -975,8 +978,8 @@ public: } }; - typedef pair<size_t, double> independentRepairTask; - typedef Triplet<size_t, double, int> dependentRepairTask; + typedef std::pair<size_t, double> independentRepairTask; + typedef std::Triplet<size_t, double, int> dependentRepairTask; struct compareIndependentTasks { bool operator()(const independentRepairTask &t1, @@ -1002,8 +1005,8 @@ public: void serialize(Archive &ar, const unsigned int version) { // ar & this->nodes_; // ar & this->simplices_; - ar & this->meshNodes_; - ar & this->meshCells_; + ar &this->meshNodes_; + ar &this->meshCells_; }; }; diff --git a/src/mesh/meshInterprocConnectivity.ipp b/src/mesh/meshInterprocConnectivity.ipp index a63be7f97..fc5c34c00 100644 --- a/src/mesh/meshInterprocConnectivity.ipp +++ b/src/mesh/meshInterprocConnectivity.ipp @@ -1,11 +1,12 @@ #pragma once +#include "qcMesh.h" namespace meshing { template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { // mark nodes on boundary - vector<bool> visitedNodes(meshNodes_.size(), false); + std::vector<bool> visitedNodes(meshNodes_.size(), false); - vector<size_t> boundaryNodeIndices; + std::vector<size_t> boundaryNodeIndices; boundaryNodeIndices.reserve(meshNodes_.size()); // reset local boundary flags and proc boundary flags @@ -46,8 +47,8 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { int noofBoundaryNodes = boundaryNodeIndices.size(); - vector<int> bcast_boundary_node_keys; - unordered_map<size_t, bool> boundary_node_keys; + std::vector<int> bcast_boundary_node_keys; + std::unordered_map<size_t, bool> boundary_node_keys; bcast_boundary_node_keys.reserve(noofBoundaryNodes); boundary_node_keys.reserve(noofBoundaryNodes); @@ -57,29 +58,29 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { static_cast<int>(node_index_to_key_[boundaryNodeIndex])); boundary_node_keys.insert( - make_pair(node_index_to_key_[boundaryNodeIndex], true)); + std::make_pair(node_index_to_key_[boundaryNodeIndex], true)); } - vector<int> noofallProcBoundaryNodesData(mpi_size); + std::vector<int> noofallProcBoundaryNodesData(mpi_size); mpi_utilities::ALLGATHER<int>(noofBoundaryNodes, noofallProcBoundaryNodesData, 1); - vector<int> displacements(mpi_size, 0); + std::vector<int> displacements(mpi_size, 0); for (int i_rank = 1; i_rank != mpi_size; ++i_rank) { displacements[i_rank] = displacements[i_rank - 1] + noofallProcBoundaryNodesData[i_rank - 1]; } - vector<int> boundary_node_keys_all_proc( + std::vector<int> boundary_node_keys_all_proc( displacements[mpi_size - 1] + noofallProcBoundaryNodesData[mpi_size - 1]); mpi_utilities::ALLGATHERV<int>(bcast_boundary_node_keys, boundary_node_keys_all_proc, noofallProcBoundaryNodesData, displacements); - vector<int> boundaryNodes_procs_delimiters(mpi_size + 1, 0); + std::vector<int> boundaryNodes_procs_delimiters(mpi_size + 1, 0); for (int i = 0; i < mpi_size; i++) { boundaryNodes_procs_delimiters[i + 1] = displacements[i] + noofallProcBoundaryNodesData[i]; @@ -90,7 +91,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { int nodeRank, previousNodeRank; size_t other_proc_boundary_node_key; - set<pair<size_t, size_t>> connected_nodes_ordered; + std::set<std::pair<size_t, size_t>> connected_nodes_ordered; previousNodeRank = 0; @@ -102,7 +103,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { // arrange nodes on processor boundaries for (size_t i = 0; i < noof_node_keys_allProcs; i++) { - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(boundaryNodes_procs_delimiters.cbegin(), boundaryNodes_procs_delimiters.cend(), i); @@ -112,12 +113,12 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { if (previousNodeRank < nodeRank) { if (connected_nodes_ordered.size() > 0) { connected_node_procs_.push_back(previousNodeRank); - connected_nodes_.push_back(vector<size_t>()); + connected_nodes_.push_back(std::vector<size_t>()); std::transform( connected_nodes_ordered.begin(), connected_nodes_ordered.end(), std::back_inserter(connected_nodes_[connected_nodes_.size() - 1]), - get_second()); + std::get_second()); } connected_nodes_ordered.clear(); @@ -129,7 +130,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { if (boundary_node_keys.find(other_proc_boundary_node_key) != boundary_node_keys.end()) { - connected_nodes_ordered.insert(make_pair( + connected_nodes_ordered.insert(std::make_pair( other_proc_boundary_node_key, meshNodes_.at(other_proc_boundary_node_key).getMeshIndex())); // nodeRank's connected @@ -146,12 +147,12 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { if (connected_nodes_ordered.size() > 0) { connected_node_procs_.push_back(previousNodeRank); - connected_nodes_.push_back(vector<size_t>()); + connected_nodes_.push_back(std::vector<size_t>()); std::transform( connected_nodes_ordered.begin(), connected_nodes_ordered.end(), std::back_inserter(connected_nodes_[connected_nodes_.size() - 1]), - get_second()); + std::get_second()); } connected_nodes_ordered.clear(); @@ -163,4 +164,4 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildInterprocConnectivity() { buildPeriodicConnectivity(); } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshNode.h b/src/mesh/meshNode.h index 96bd53840..f85db3b7a 100644 --- a/src/mesh/meshNode.h +++ b/src/mesh/meshNode.h @@ -10,9 +10,6 @@ // ! none of its functions do anything if #define NDEBUG is there #include <assert.h> -using namespace std; -using namespace geometry; - namespace meshing { template <int D> class node { @@ -30,7 +27,7 @@ public: node() : key_(), meshIndex_(), periodicBoundaryFlag_(false), procBoundaryFlag_(false) { - coordinate_ = filled_array<array<double, D>>(0.0); + coordinate_ = std::filled_array<std::array<double, D>>(0.0); } node(const point<D> &p) @@ -81,9 +78,9 @@ public: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { - ar & this->coordinate_; - ar & this->key_; - ar & this->meshIndex_; + ar &this->coordinate_; + ar &this->key_; + ar &this->meshIndex_; }; }; @@ -92,4 +89,4 @@ struct DerefIterator : public std::unary_function<Handle, T> { //! Return the object to which the handle \c x points. T operator()(Handle x) const { return (x->second).getPoint(); } }; -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshPeriodicConnectivity.ipp b/src/mesh/meshPeriodicConnectivity.ipp index 098851e38..5cda4a0ec 100644 --- a/src/mesh/meshPeriodicConnectivity.ipp +++ b/src/mesh/meshPeriodicConnectivity.ipp @@ -1,8 +1,9 @@ #pragma once +#include "qcMesh.h" namespace meshing { template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { - typedef typename vector<point<D>>::iterator pointIt; + typedef typename std::vector<point<D>>::iterator pointIt; typedef DerefPointIterator<pointIt, point<D>> pointLocator; typedef Box<point<D>, D> box; @@ -16,8 +17,8 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { // build similar to interproc connectivity. - vector<int> periodicBoundaryNodeKeys; - vector<_node_> periodicBoundaryNodes; + std::vector<int> periodicBoundaryNodeKeys; + std::vector<_node_> periodicBoundaryNodes; periodicBoundaryNodeKeys.reserve(meshNodes_.size()); periodicBoundaryNodes.reserve(meshNodes_.size()); @@ -51,25 +52,25 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { int noofBoundaryNodes = periodicBoundaryNodes.size(); - vector<int> noofallProcBoundaryNodes(mpi_size); + std::vector<int> noofallProcBoundaryNodes(mpi_size); mpi_utilities::ALLGATHER1D<int>(noofBoundaryNodes, noofallProcBoundaryNodes); - vector<int> displacements(mpi_size, 0); + std::vector<int> displacements(mpi_size, 0); for (int i_rank = 1; i_rank != mpi_size; ++i_rank) { displacements[i_rank] = displacements[i_rank - 1] + noofallProcBoundaryNodes[i_rank - 1]; } - vector<int> periodicBoundaryKeysAllProcs( + std::vector<int> periodicBoundaryKeysAllProcs( displacements[mpi_size - 1] + noofallProcBoundaryNodes[mpi_size - 1]); mpi_utilities::ALLGATHERV<int>(periodicBoundaryNodeKeys, periodicBoundaryKeysAllProcs, noofallProcBoundaryNodes, displacements); - vector<_node_> periodicBoundaryNodesAllProcs( + std::vector<_node_> periodicBoundaryNodesAllProcs( displacements[mpi_size - 1] + noofallProcBoundaryNodes[mpi_size - 1]); mpi_utilities::ALLGATHERV_CUSTOM<_node_, D>( @@ -88,7 +89,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { uniquePointContainer<_node_, D> uniqueBoundaryNodes( boundaryNodesBounds.lower_, boundaryNodesBounds.upper_); - vector<int> uniquePeriodicKeys; + std::vector<int> uniquePeriodicKeys; uniqueBoundaryNodes.reserve(periodicBoundaryNodesAllProcs.size()); uniquePeriodicKeys.reserve(periodicBoundaryNodesAllProcs.size()); @@ -100,7 +101,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { // 1. Gather all nodes on boundaries. // a. MPI_Gather(boundary nodes) // b. get unique boundary nodes - vector<vector<int>> ranksOfUniqueNodes; + std::vector<std::vector<int>> ranksOfUniqueNodes; ranksOfUniqueNodes.reserve(periodicBoundaryKeysAllProcs.size()); assert(periodicBoundaryKeysAllProcs.size() == @@ -109,7 +110,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { for (int nodeIdx = 0; nodeIdx < periodicBoundaryKeysAllProcs.size(); nodeIdx++) { - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(displacements.cbegin(), displacements.cend(), nodeIdx); nodeRank = distance(displacements.cbegin(), it) - 1; @@ -120,13 +121,13 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { if (added) { uniquePeriodicKeys.push_back(periodicBoundaryKeysAllProcs[nodeIdx]); - ranksOfUniqueNodes.push_back(vector<int>{nodeRank}); + ranksOfUniqueNodes.push_back(std::vector<int>{nodeRank}); } else { ranksOfUniqueNodes[addedIndex].push_back(nodeRank); } } - vector<typename vector<_node_>::const_iterator> periodicImages; + std::vector<typename std::vector<_node_>::const_iterator> periodicImages; size_t nodeIndex, nodeKey; int imageIndex; @@ -135,9 +136,9 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { _node_ nodePeriodicPoint; _periodicNodeImage_ periodicNodeImage; - int n_periods = count(periodicFlags.begin(), periodicFlags.end(), true); + int n_periods = std::count(periodicFlags.begin(), periodicFlags.end(), true); - vector<array<int, D>> periodicOffsets; + std::vector<std::array<int, D>> periodicOffsets; int n_offsets; n_offsets = 0; @@ -217,7 +218,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { nodeIndex = meshNodes_.at(nodeKey).getMeshIndex(); nodePeriodicImages_.insert( - make_pair(nodeIndex, vector<_periodicNodeImage_>{})); + std::make_pair(nodeIndex, std::vector<_periodicNodeImage_>{})); for (int offsetIndex = 0; offsetIndex < periodicOffsets.size(); offsetIndex++) { @@ -300,7 +301,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { // 3. find the original key from the images for (const auto &np : nodePeriodicImages_) { if (np.second.size() != 0) { - maxImageDistance = numeric_limits<double>::min(); + maxImageDistance = std::numeric_limits<double>::min(); imageRank = mpi_size + 1; farthestIndex = -1; @@ -323,10 +324,10 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { assert(farthestIndex != -1); originalKeysOfPeriodicImages_.insert( - make_pair(nodeIndex, np.second[farthestIndex].second)); + std::make_pair(nodeIndex, np.second[farthestIndex].second)); - offsetsOfPeriodicImages_.insert( - make_pair(nodeIndex, nodePoint - np.second[farthestIndex].third)); + offsetsOfPeriodicImages_.insert(std::make_pair( + nodeIndex, nodePoint - np.second[farthestIndex].third)); // cout<<np.second[farthestIndex].second<<" , "<<nodePoint<<" , // "<<np.second[farthestIndex].third<<" , "<< nodePoint - @@ -360,11 +361,11 @@ template <int D, int K> void KSimplexDMesh<D, K>::buildPeriodicConnectivity() { // now find the periodic images - // unordered_map<size_t, vector<_periodicNodeImage_>> nodePeriodicImages_ + // unordered_map<size_t, std::vector<_periodicNodeImage_>> nodePeriodicImages_ // unordered_map<size_t, size_t> originalKeysOfPeriodicImages_ // the original keys are determined // by key of node with lowest coordinate } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshRepairDependent.ipp b/src/mesh/meshRepairDependent.ipp index dc610ed53..788cd8c70 100644 --- a/src/mesh/meshRepairDependent.ipp +++ b/src/mesh/meshRepairDependent.ipp @@ -1,4 +1,5 @@ #pragma once +#include "qcMesh.h" #include "vtkIO.h" #include <removeEdge.h> @@ -8,8 +9,8 @@ template <int D, int K> template <typename edgeRemoval> bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( const int &_taskRank, const _edge_ &_edge, edgeRemoval &_edgeEraser3D, - vector<KSimplexDMesh<D, K>::_pairKey_> &_elementsToBeRemoved, - unordered_map<size_t, KSimplexDMesh<D, K>::_simplexCell_> + std::vector<KSimplexDMesh<D, K>::_pairKey_> &_elementsToBeRemoved, + std::unordered_map<size_t, KSimplexDMesh<D, K>::_simplexCell_> &_elementsToBeInserted) { typedef KSimplexDMesh<D, K>::_pairKey_ _pairKey_; typedef KSimplexDMesh<D, K>::_ind_simplex_ _ind_simplex_; @@ -23,17 +24,17 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( bool isEdgeOnBoundary; int localIndex; - array<int, 4> adjacencySizesAndFixedPointIds; - array<double, 2 * D> eraserPointsAndChecks; + std::array<int, 4> adjacencySizesAndFixedPointIds; + std::array<double, 2 * D> eraserPointsAndChecks; - vector<_node_> ringVertices; - vector<size_t> ringVertexIds; + std::vector<_node_> ringVertices; + std::vector<size_t> ringVertexIds; size_t source, target; _node_ sourcePoint, targetPoint; - vector<double> ringVertexCoords; - vector<int> adjacentElementKeysExc; + std::vector<double> ringVertexCoords; + std::vector<int> adjacentElementKeysExc; bool edgeRemovalSolve; @@ -169,10 +170,10 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( const int numberOfTriangles = _edgeEraser3D.getNumberOfTriangles(); - vector<_pairKey_> sourceTetra(numberOfTriangles), + std::vector<_pairKey_> sourceTetra(numberOfTriangles), targetTetra(numberOfTriangles); - array<int, K> ring_triangle; + std::array<int, K> ring_triangle; _simplexCell_ newCell; for (int i = 0; i < numberOfTriangles; ++i) { @@ -183,20 +184,20 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( newCell.setNode(make_pair(_taskRank, ringVertexIds[ring_triangle[d]]), d); } - newCell.setNode(make_pair(_taskRank, target), K); - newCell.setPairKey(make_pair(_taskRank, newCellKey_)); - _elementsToBeInserted.insert(make_pair(newCellKey_, newCell)); - targetTetra[i] = make_pair(_taskRank, newCellKey_); + newCell.setNode(std::make_pair(_taskRank, target), K); + newCell.setPairKey(std::make_pair(_taskRank, newCellKey_)); + _elementsToBeInserted.insert(std::make_pair(newCellKey_, newCell)); + targetTetra[i] = std::make_pair(_taskRank, newCellKey_); ++newCellKey_; - newCell.setNode(make_pair(_taskRank, source), 0); + newCell.setNode(std::make_pair(_taskRank, source), 0); for (int d = 0; d < K; d++) { - newCell.setNode(make_pair(_taskRank, ringVertexIds[ring_triangle[d]]), - d + 1); + newCell.setNode( + std::make_pair(_taskRank, ringVertexIds[ring_triangle[d]]), d + 1); } - newCell.setPairKey(make_pair(_taskRank, newCellKey_)); - _elementsToBeInserted.insert(make_pair(newCellKey_, newCell)); - sourceTetra[i] = make_pair(_taskRank, newCellKey_); + newCell.setPairKey(std::make_pair(_taskRank, newCellKey_)); + _elementsToBeInserted.insert(std::make_pair(newCellKey_, newCell)); + sourceTetra[i] = std::make_pair(_taskRank, newCellKey_); ++newCellKey_; // We set the newCellKey_ to same for all ranks @@ -313,9 +314,9 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( // maximumQualityResidualIncidentElements)) // { // #ifdef DEBUG_INTERMEDIATE_EDGEREMOVAL - // unordered_map<size_t, _ind_simplex_> outputTets; - // unordered_map<size_t, _node_> outputNodes; - // unordered_map<size_t, int> ranksOutputTets; + // std::unordered_map<size_t, _ind_simplex_> outputTets; + // std::unordered_map<size_t, _node_> outputNodes; + // std::unordered_map<size_t, int> ranksOutputTets; // getSimplicesFromCells(_elementsToBeRemoved.begin(), // _elementsToBeRemoved.end(), outputTets, @@ -327,13 +328,13 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( // const int numberOfTriangles = // _edgeEraser3D.getNumberOfTriangles(); - // // unordered_map<size_t, _simplexCell_> + // // std::unordered_map<size_t, _simplexCell_> // _elementsToBeInserted; - // vector<_pairKey_> sourceTetra(numberOfTriangles), + // std::vector<_pairKey_> sourceTetra(numberOfTriangles), // targetTetra(numberOfTriangles); - // array<int, K> ring_triangle; + // std::array<int, K> ring_triangle; // _simplexCell_ newCell; // // if we broadcast edgeRemoval object, then we can simply do @@ -348,24 +349,24 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( // for(int d=0; d<K; d++) // { - // newCell.setNode(make_pair(mpi_rank, + // newCell.setNode(std::make_pair(mpi_rank, // ringVertexIds[ring_triangle[d]]), d); // } - // newCell.setNode(make_pair(mpi_rank, target), K); - // newCell.setPairKey(make_pair(mpi_rank, - // newCellKey_)); _elementsToBeInserted.insert(make_pair(newCellKey_, - // newCell)); targetTetra[i] = make_pair(mpi_rank, newCellKey_); + // newCell.setNode(std::make_pair(mpi_rank, target), K); + // newCell.setPairKey(std::make_pair(mpi_rank, + // newCellKey_)); _elementsToBeInserted.insert(std::make_pair(newCellKey_, + // newCell)); targetTetra[i] = std::make_pair(mpi_rank, newCellKey_); // ++newCellKey_; - // newCell.setNode(make_pair(mpi_rank, source), 0); + // newCell.setNode(std::make_pair(mpi_rank, source), 0); // for(int d=0; d<K; d++) // { - // newCell.setNode(make_pair(mpi_rank, + // newCell.setNode(std::make_pair(mpi_rank, // ringVertexIds[ring_triangle[d]]), d+1); // } - // newCell.setPairKey(make_pair(mpi_rank, - // newCellKey_)); _elementsToBeInserted.insert(make_pair(newCellKey_, - // newCell)); sourceTetra[i] = make_pair(mpi_rank, newCellKey_); + // newCell.setPairKey(std::make_pair(mpi_rank, + // newCellKey_)); _elementsToBeInserted.insert(std::make_pair(newCellKey_, + // newCell)); sourceTetra[i] = std::make_pair(mpi_rank, newCellKey_); // ++newCellKey_; // } @@ -473,9 +474,9 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( // } // #ifdef DEBUG_INTERMEDIATE_EDGEREMOVAL - // unordered_map<size_t, _ind_simplex_> InsertedTets; - // unordered_map<size_t, _node_> InsertedNodes; - // unordered_map<size_t, int> ranks; + // std::unordered_map<size_t, _ind_simplex_> InsertedTets; + // std::unordered_map<size_t, _node_> InsertedNodes; + // std::unordered_map<size_t, int> ranks; // InsertedTets.reserve(_elementsToBeInserted.size()); // _ind_simplex_ simplex; @@ -489,15 +490,15 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( // if(InsertedNodes.find(nodeKey) == // InsertedNodes.end()) // { - // InsertedNodes.insert(make_pair(nodeKey, + // InsertedNodes.insert(std::make_pair(nodeKey, // getMeshPointFromKey(nodeKey))); // } // simplex[d] = nodeKey; // } - // InsertedTets.insert(make_pair(s.first, simplex)); - // ranks.insert(make_pair(s.first, + // InsertedTets.insert(std::make_pair(s.first, simplex)); + // ranks.insert(std::make_pair(s.first, // s.second.getPairKey().first)); // } @@ -506,7 +507,7 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( // ranks, "inserted_elements"); #endif // // // delete incident_elements elements - // // vector<_pairKey_> otherRankElementsToBeDeleted; + // // std::vector<_pairKey_> otherRankElementsToBeDeleted; // // eraseCells(_elementsToBeRemoved.begin(), // _elementsToBeRemoved.end(), @@ -520,4 +521,4 @@ bool KSimplexDMesh<D, K>::tryEdgeRemovalDependent( return removedEdge; } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshRepairLocal.ipp b/src/mesh/meshRepairLocal.ipp index 1e9bde49b..3e16b8afe 100644 --- a/src/mesh/meshRepairLocal.ipp +++ b/src/mesh/meshRepairLocal.ipp @@ -1,5 +1,6 @@ #pragma once +#include "qcMesh.h" #include "vtkIO.h" #include <removeEdge.h> @@ -9,8 +10,8 @@ template <int D, int K> template <typename edgeRemoval> bool KSimplexDMesh<D, K>::tryEdgeRemoval( const _edge_ &_edge, edgeRemoval &_edgeEraser3D, - vector<KSimplexDMesh<D, K>::_pairKey_> &_elementsToBeRemoved, - unordered_map<size_t, KSimplexDMesh<D, K>::_simplexCell_> + std::vector<KSimplexDMesh<D, K>::_pairKey_> &_elementsToBeRemoved, + std::unordered_map<size_t, KSimplexDMesh<D, K>::_simplexCell_> &_elementsToBeInserted) { typedef KSimplexDMesh<D, K>::_pairKey_ _pairKey_; typedef KSimplexDMesh<D, K>::_ind_simplex_ _ind_simplex_; @@ -19,8 +20,8 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( bool removedEdge = false; - // vector<_pairKey_> _elementsToBeRemoved; - // vector<size_t> addedElements; + // std::vector<_pairKey_> _elementsToBeRemoved; + // std::vector<size_t> addedElements; double volumeIncidentElements; double maximumQualityResidualIncidentElements; @@ -28,8 +29,8 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( bool isEdgeOnBoundary; int localIndex; - vector<_node_> ringVertices; - vector<size_t> ringVertexIds; + std::vector<_node_> ringVertices; + std::vector<size_t> ringVertexIds; isEdgeOnBoundary = getIncidentCellsInOrder( _edge, back_inserter(_elementsToBeRemoved), ringVertices, ringVertexIds); @@ -51,9 +52,9 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( if (_edgeEraser3D.solve(volumeIncidentElements, maximumQualityResidualIncidentElements)) { // #ifdef DEBUG_INTERMEDIATE_EDGEREMOVAL - // unordered_map<size_t, _ind_simplex_> outputTets; - // unordered_map<size_t, _node_> outputNodes; - // unordered_map<size_t, int> ranksOutputTets; + // std::unordered_map<size_t, _ind_simplex_> outputTets; + // std::unordered_map<size_t, _node_> outputNodes; + // std::unordered_map<size_t, int> ranksOutputTets; // getSimplicesFromCells(_elementsToBeRemoved.begin(), // _elementsToBeRemoved.end(), outputTets, @@ -65,12 +66,12 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( const int numberOfTriangles = _edgeEraser3D.getNumberOfTriangles(); - // unordered_map<size_t, _simplexCell_> _elementsToBeInserted; + // std::unordered_map<size_t, _simplexCell_> _elementsToBeInserted; - vector<_pairKey_> sourceTetra(numberOfTriangles), + std::vector<_pairKey_> sourceTetra(numberOfTriangles), targetTetra(numberOfTriangles); - array<int, K> ring_triangle; + std::array<int, K> ring_triangle; _simplexCell_ newCell; for (int i = 0; i < numberOfTriangles; ++i) { @@ -78,23 +79,23 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( newCell.resetNeighbours(); for (int d = 0; d < K; d++) { - newCell.setNode(make_pair(mpi_rank, ringVertexIds[ring_triangle[d]]), - d); + newCell.setNode( + std::make_pair(mpi_rank, ringVertexIds[ring_triangle[d]]), d); } - newCell.setNode(make_pair(mpi_rank, target), K); - newCell.setPairKey(make_pair(mpi_rank, newCellKey_)); - _elementsToBeInserted.insert(make_pair(newCellKey_, newCell)); - targetTetra[i] = make_pair(mpi_rank, newCellKey_); + newCell.setNode(std::make_pair(mpi_rank, target), K); + newCell.setPairKey(std::make_pair(mpi_rank, newCellKey_)); + _elementsToBeInserted.insert(std::make_pair(newCellKey_, newCell)); + targetTetra[i] = std::make_pair(mpi_rank, newCellKey_); ++newCellKey_; - newCell.setNode(make_pair(mpi_rank, source), 0); + newCell.setNode(std::make_pair(mpi_rank, source), 0); for (int d = 0; d < K; d++) { - newCell.setNode(make_pair(mpi_rank, ringVertexIds[ring_triangle[d]]), - d + 1); + newCell.setNode( + std::make_pair(mpi_rank, ringVertexIds[ring_triangle[d]]), d + 1); } - newCell.setPairKey(make_pair(mpi_rank, newCellKey_)); - _elementsToBeInserted.insert(make_pair(newCellKey_, newCell)); - sourceTetra[i] = make_pair(mpi_rank, newCellKey_); + newCell.setPairKey(std::make_pair(mpi_rank, newCellKey_)); + _elementsToBeInserted.insert(std::make_pair(newCellKey_, newCell)); + sourceTetra[i] = std::make_pair(mpi_rank, newCellKey_); ++newCellKey_; } @@ -195,9 +196,9 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( } // #ifdef DEBUG_INTERMEDIATE_EDGEREMOVAL - // unordered_map<size_t, _ind_simplex_> InsertedTets; - // unordered_map<size_t, _node_> InsertedNodes; - // unordered_map<size_t, int> ranks; + // std::unordered_map<size_t, _ind_simplex_> InsertedTets; + // std::unordered_map<size_t, _node_> InsertedNodes; + // std::unordered_map<size_t, int> ranks; // InsertedTets.reserve(_elementsToBeInserted.size()); // _ind_simplex_ simplex; @@ -211,14 +212,14 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( // if(InsertedNodes.find(nodeKey) == // InsertedNodes.end()) // { - // InsertedNodes.insert(make_pair(nodeKey, + // InsertedNodes.insert(std::make_pair(nodeKey, // getMeshPointFromKey(nodeKey))); // } // simplex[d] = nodeKey; // } - // InsertedTets.insert(make_pair(s.first, simplex)); - // ranks.insert(make_pair(s.first, + // InsertedTets.insert(std::make_pair(s.first, simplex)); + // ranks.insert(std::make_pair(s.first, // s.second.getPairKey().first)); // } @@ -226,7 +227,7 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( // ranks, "inserted_elements"); #endif // // delete incident_elements elements - // vector<_pairKey_> otherRankElementsToBeDeleted; + // std::vector<_pairKey_> otherRankElementsToBeDeleted; // eraseCells(_elementsToBeRemoved.begin(), _elementsToBeRemoved.end(), // back_inserter(otherRankElementsToBeDeleted)); @@ -313,9 +314,9 @@ bool KSimplexDMesh<D, K>::tryEdgeRemoval( */ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { - array<_node_, K + 1> simplex; + std::array<_node_, K + 1> simplex; - typedef Triplet<size_t, double, int> dependentTask; + typedef std::Triplet<size_t, double, int> dependentTask; typedef KSimplexDMesh<D, K>::_simplexCell_ _simplexCell_; typedef KSimplexDMesh<D, K>::_pairKey_ _pairKey_; @@ -359,9 +360,9 @@ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { EdgeEraser_3 edgeEraser3D; - unordered_map<size_t, _simplexCell_> newCells; - vector<_pairKey_> cellsToDelete; - vector<_pairKey_> otherRanksCellsToDelete; + std::unordered_map<size_t, _simplexCell_> newCells; + std::vector<_pairKey_> cellsToDelete; + std::vector<_pairKey_> otherRanksCellsToDelete; while (!independentBadElements.empty()) { optimize_result = false; @@ -423,8 +424,8 @@ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { buildAdjacencyHalo(true, true); // now gather dependent bad elements - vector<int> dependentBadElementIDs; - vector<double> dependentBadElementResidues; + std::vector<int> dependentBadElementIDs; + std::vector<double> dependentBadElementResidues; for (const auto &keyCell : meshCells_) { if (simplexMetricResidual<K>(getSimplex(keyCell.first)) > 1.0) { @@ -450,9 +451,9 @@ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { } } - vector<int> allProcsNoofDependentTasks(mpi_size); - vector<int> displacements(mpi_size, 0); - vector<int> delimiters(mpi_size + 1, 0); + std::vector<int> allProcsNoofDependentTasks(mpi_size); + std::vector<int> displacements(mpi_size, 0); + std::vector<int> delimiters(mpi_size + 1, 0); mpi_utilities::ALLGATHER<int>(dependentBadElementResidues.size(), allProcsNoofDependentTasks, 1); @@ -469,8 +470,8 @@ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { delimiters[mpi_size] = totalDependentTasks; // gather all dependent tasks. Need rank, quality residue, and element id - vector<int> allProcDependentTaskKeys(totalDependentTasks); - vector<double> allProcDependentTaskResidues(totalDependentTasks); + std::vector<int> allProcDependentTaskKeys(totalDependentTasks); + std::vector<double> allProcDependentTaskResidues(totalDependentTasks); mpi_utilities::ALLGATHERV<int>(dependentBadElementIDs, allProcDependentTaskKeys, @@ -490,7 +491,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { // assemble the dependent tasks in the order of decreasing quality residual for (int i = 0; i < totalDependentTasks; i++) { - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(delimiters.cbegin(), delimiters.cend(), i); task_rank = distance(delimiters.cbegin(), it) - 1; @@ -618,9 +619,9 @@ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { // noofCellsToDelete = cellsToDelete.size(); // noofNodesToAdd = 0; - // vector<unsigned int> newClusterIntDataSend; - // vector<double> newClusterDoubleDataSend; - // vector<unsigned int> newClusterNodes; + // std::vector<unsigned int> newClusterIntDataSend; + // std::vector<double> newClusterDoubleDataSend; + // std::vector<unsigned int> newClusterNodes; // unordered_set<size_t> visitedNodes; @@ -660,7 +661,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::repairMeshLocal() { // make_move_iterator(newClusterNodes.begin()), // make_move_iterator(newClusterNodes.end())); - // vector<unsigned int>().swap(newClusterNodes); + // std::vector<unsigned int>().swap(newClusterNodes); // for(int i=0; i<cellsToDelete.size(); i++) // { diff --git a/src/mesh/meshSimplexCell.h b/src/mesh/meshSimplexCell.h index 81e847924..2ed3931be 100644 --- a/src/mesh/meshSimplexCell.h +++ b/src/mesh/meshSimplexCell.h @@ -1,4 +1,3 @@ - #pragma once #include "StandardHeaders.h" @@ -11,9 +10,6 @@ // ! none of its functions do anything if #define NDEBUG is there #include <assert.h> -using namespace std; -using namespace geometry; - namespace meshing { template <int D, int K> class simplexCell { public: @@ -21,10 +17,10 @@ public: private: // keys of nodes making the cell - array<_pairKey_, K + 1> nodes_; + std::array<_pairKey_, K + 1> nodes_; // face neighoburs of the cell. All other neighbours (edge and node) // are extracted from these, if needed. - array<_pairKey_, K + 1> neighbours_; + std::array<_pairKey_, K + 1> neighbours_; _pairKey_ key_; @@ -33,20 +29,21 @@ private: public: simplexCell() : nodes_(), neighbours_(), key_(), meshIndex_() {} - simplexCell(const array<size_t, K + 1> &_nodeIds, const size_t &id) + simplexCell(const std::array<size_t, K + 1> &_nodeIds, const size_t &id) : neighbours_(), meshIndex_() { for (int d = 0; d < K + 1; d++) { - nodes_[d] = make_pair(mpi_rank, _nodeIds[d]); + nodes_[d] = std::make_pair(mpi_rank, _nodeIds[d]); } - key_ = make_pair(mpi_rank, id); + key_ = std::make_pair(mpi_rank, id); } - simplexCell setCell(const array<size_t, K + 1> &_nodeIds, const size_t &id) { + simplexCell setCell(const std::array<size_t, K + 1> &_nodeIds, + const size_t &id) { for (int d = 0; d < K + 1; d++) { - nodes_[d] = make_pair(mpi_rank, _nodeIds[d]); + nodes_[d] = std::make_pair(mpi_rank, _nodeIds[d]); } - key_ = make_pair(mpi_rank, id); + key_ = std::make_pair(mpi_rank, id); return (*this); } @@ -73,9 +70,9 @@ public: _pairKey_ getNode(const int &d) { return nodes_[d]; } - array<size_t, K + 1> getNodes() const { return nodes_; } + std::array<size_t, K + 1> getNodes() const { return nodes_; } void resetNeighbours() { - neighbours_.fill(make_pair(-1, numeric_limits<size_t>::max())); + neighbours_.fill(std::make_pair(-1, std::numeric_limits<size_t>::max())); } bool hasNode(const _pairKey_ &p) const { return hasElement(nodes_, p); } @@ -117,10 +114,10 @@ public: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { - ar & this->neighbours_; - ar & this->nodes_; - ar & this->key_; - ar & this->meshIndex_; + ar &this->neighbours_; + ar &this->nodes_; + ar &this->key_; + ar &this->meshIndex_; }; }; -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshTopology.ipp b/src/mesh/meshTopology.ipp index 56c924745..44998ed43 100644 --- a/src/mesh/meshTopology.ipp +++ b/src/mesh/meshTopology.ipp @@ -6,6 +6,7 @@ \author P. Gupta */ #pragma once +#include "qcMesh.h" namespace meshing { @@ -13,7 +14,7 @@ template <int D, int K> inline void KSimplexDMesh<D, K>::buildAdjacencyHalo(const bool haloToHalo, const bool haloToLocal) { - vector<size_t> noof_incidences(meshNodes_.size(), size_t(0)); + std::vector<size_t> noof_incidences(meshNodes_.size(), size_t(0)); // also use halo simplices. Only add to nodes that belong to this rank for (const auto &s : halo_mesh_simplices_) { @@ -50,7 +51,7 @@ inline void KSimplexDMesh<D, K>::buildAdjacencyHalo(const bool haloToHalo, assert(vertex_adj_pointers_[vertex_adj_pointers_.size() - 1] == vertex_adj_.end()); - vector<vector<_pairKey_>::iterator> vs_i(meshNodes_.size()); + std::vector<std::vector<_pairKey_>::iterator> vs_i(meshNodes_.size()); for (size_t nd = 0; nd != meshNodes_.size(); nd++) { vs_i[nd] = vertex_adj_pointers_[nd]; } @@ -155,7 +156,7 @@ inline void KSimplexDMesh<D, K>::buildAdjacencyHalo(const bool haloToHalo, template <int D, int K> inline void KSimplexDMesh<D, K>::buildNodeCellAdjacency() { - vector<size_t> noof_incidences(meshNodes_.size(), size_t(0)); + std::vector<size_t> noof_incidences(meshNodes_.size(), size_t(0)); for (const auto &s : meshCells_) { for (int d = 0; d < K + 1; d++) { @@ -182,7 +183,7 @@ inline void KSimplexDMesh<D, K>::buildNodeCellAdjacency() { assert(vertex_adj_pointers_[vertex_adj_pointers_.size() - 1] == vertex_adj_.end()); - vector<vector<_pairKey_>::iterator> vs_i(meshNodes_.size()); + std::vector<std::vector<_pairKey_>::iterator> vs_i(meshNodes_.size()); for (size_t nd = 0; nd != meshNodes_.size(); nd++) { vs_i[nd] = vertex_adj_pointers_[nd]; } @@ -220,7 +221,7 @@ inline void KSimplexDMesh<D, K>::buildFaceCellAdjacency(size_t &_noofa) { // unordered_map<size_t, _ind_simplex_> outputTets; // unordered_map<size_t, _node_> outputNodes; // unordered_map<size_t, int> ranksOutputTets; - // vector<_pairKey_> incidentElements; + // std::vector<_pairKey_> incidentElements; for (auto &s : meshCells_) { s.second.resetNeighbours(); @@ -265,12 +266,12 @@ inline void KSimplexDMesh<D, K>::buildMeshFaces(size_t _noofa) { _pairKey_ adj_simplex_key; // ! build faces from face adjacencies (needed for ParMetis) // only needed for re-partitioning. - unordered_map<size_t, array<bool, K + 1>> visited_faces_simplices; + std::unordered_map<size_t, std::array<bool, K + 1>> visited_faces_simplices; visited_faces_simplices.reserve(meshCells_.size()); for (const auto &s : meshCells_) { visited_faces_simplices.insert( - make_pair(s.first, filled_array<array<bool, K + 1>>(false))); + make_pair(s.first, std::filled_array<std::array<bool, K + 1>>(false))); } faces_.clear(); @@ -344,10 +345,10 @@ inline void KSimplexDMesh<D, K>::buildMeshTopology(bool _build_node_adj, // _pairKey_ adj_simplex_key; - // // unordered_map<size_t, _ind_simplex_> outputTets; - // // unordered_map<size_t, _node_> outputNodes; - // // unordered_map<size_t, int> ranksOutputTets; - // // vector<_pairKey_> incidentElements; + // // std::unordered_map<size_t, _ind_simplex_> outputTets; + // // std::unordered_map<size_t, _node_> outputNodes; + // // std::unordered_map<size_t, int> ranksOutputTets; + // // std::vector<_pairKey_> incidentElements; // for(auto &s : meshCells_) // { @@ -397,4 +398,4 @@ inline void KSimplexDMesh<D, K>::buildMeshTopology(bool _build_node_adj, // buildMeshFaces(noof_faces_approx); // } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshTraversal.ipp b/src/mesh/meshTraversal.ipp index 6f40af084..1c7517a3a 100644 --- a/src/mesh/meshTraversal.ipp +++ b/src/mesh/meshTraversal.ipp @@ -8,10 +8,10 @@ */ #pragma once - +#include "qcMesh.h" namespace meshing { -typedef pair<int, size_t> _pairKey_; +typedef std::pair<int, size_t> _pairKey_; template <int D, int K> inline int KSimplexDMesh<D, K>::computeOtherIndex(const int &i, const int &j, @@ -297,10 +297,9 @@ inline bool KSimplexDMesh<D, K>::ifEdgeOnBoundary(const _edge_ &_e) { template <int D, int K> template <typename OutputIterator> -bool KSimplexDMesh<D, K>::getIncidentCellsInOrder(const _edge_ &_edge, - OutputIterator output, - vector<_node_> &_ring, - vector<size_t> &_ringIDs) { +bool KSimplexDMesh<D, K>::getIncidentCellsInOrder( + const _edge_ &_edge, OutputIterator output, std::vector<_node_> &_ring, + std::vector<size_t> &_ringIDs) { _ring.clear(); _ringIDs.clear(); @@ -526,8 +525,9 @@ bool KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: getIncidentCellsInOrder(const _edge_ &_edge, const size_t &node_a, const size_t &node_b, const _node_ &point_a, const _node_ &point_b, OutputIterator output, - vector<_node_> &_ring, vector<size_t> &_ringIDs, - vector<_node_> &_sourceToRingProjectors, + std::vector<_node_> &_ring, + std::vector<size_t> &_ringIDs, + std::vector<_node_> &_sourceToRingProjectors, _node_ &_sourceToTargetProjector) { _ring.clear(); _ringIDs.clear(); @@ -743,7 +743,7 @@ void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: E.second = Base::getSimplexNodeIndex(incident_simplex, _node_a); E.third = Base::getSimplexNodeIndex(incident_simplex, _node_b); - vector<_pairKey_> incidentCells; + std::vector<_pairKey_> incidentCells; bool EOnBoundary = Base::getIncidentCellsInOrder(E, std::back_inserter(incidentCells)); @@ -803,9 +803,9 @@ bool KSimplexDMesh<D, K>::getIncidentFacesOnFace( _edge_ uw(_face.first, u, w); // get incident cells on edges - vector<_pairKey_> incident_cells_uv; - vector<_pairKey_> incident_cells_vw; - vector<_pairKey_> incident_cells_uw; + std::vector<_pairKey_> incident_cells_uv; + std::vector<_pairKey_> incident_cells_vw; + std::vector<_pairKey_> incident_cells_uw; uv_b = getIncidentCellsInOrder(uv, back_inserter(incident_cells_uv)); vw_b = getIncidentCellsInOrder(vw, back_inserter(incident_cells_vw)); @@ -830,4 +830,4 @@ bool KSimplexDMesh<D, K>::getIncidentFacesOnFace( } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshTrim.ipp b/src/mesh/meshTrim.ipp index f705bbbd8..f3f5c49a7 100644 --- a/src/mesh/meshTrim.ipp +++ b/src/mesh/meshTrim.ipp @@ -5,6 +5,7 @@ \brief Implementation of tetrahedral mesh trim */ #pragma once +#include "qcMesh.h" namespace meshing { @@ -13,7 +14,7 @@ void KSimplexDMesh<D, K>::trim(const Box<point<D>, D> &_domain) { typedef KSimplexDMesh<D, K>::_pairKey_ _pairKey_; - vector<_pairKey_> elements_to_remove; + std::vector<_pairKey_> elements_to_remove; elements_to_remove.reserve(meshCells_.size()); _simplex_ simplex; @@ -52,7 +53,7 @@ void KSimplexDMesh<D, K>::trim(const Box<point<D>, D> &_domain) { } // remove these degenerate elements on the surface - vector<_pairKey_> remainingElements; + std::vector<_pairKey_> remainingElements; eraseCells(elements_to_remove.begin(), elements_to_remove.end(), back_inserter(remainingElements)); @@ -75,7 +76,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // and build only halo to local connectivity Base::buildAdjacencyHalo(false, true); - array<_node_, K + 1> simplex; + std::array<_node_, K + 1> simplex; typename Base::independentRepairTask independentTask; typename Base::dependentRepairTask dependentTask; @@ -90,14 +91,14 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, decltype(typename Base::simplexQualityCompareTasks())> dependentBadElements; - vector<size_t> dependentBadElementIDs; - vector<double> dependentBadElementResidues; + std::vector<size_t> dependentBadElementIDs; + std::vector<double> dependentBadElementResidues; - vector<size_t> allProcDependentTaskKeys; - vector<double> allProcDependentTaskResidues; + std::vector<size_t> allProcDependentTaskKeys; + std::vector<double> allProcDependentTaskResidues; - vector<int> allProcsNoofDependentTasks(mpi_size); - vector<int> displacements(mpi_size, 0); + std::vector<int> allProcsNoofDependentTasks(mpi_size); + std::vector<int> displacements(mpi_size, 0); int totalDependentTasks, task_rank; @@ -136,7 +137,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, size_t si; _pairKey_ cellKeyToDelete, neighbourKey; - vector<_pairKey_> cellsToDelete; + std::vector<_pairKey_> cellsToDelete; while (!independentBadElements.empty()) { si = independentBadElements.top().first; @@ -246,7 +247,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // assemble the dependent tasks in the order of decreasing quality residual for (int i = 0; i < totalDependentTasks; i++) { - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(displacements.cbegin(), displacements.cend(), i); task_rank = distance(displacements.cbegin(), it) - 1; @@ -356,7 +357,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // // assemble the dependent tasks in the order of decreasing quality // residual for(int i=0; i<totalDependentTasks; i++) // { - // const vector<int>::const_iterator it = + // const std::vector<int>::const_iterator it = // upper_bound(displacements.cbegin(), // displacements.cend(), i); // task_rank = distance(displacements.cbegin(), it) - 1; @@ -373,4 +374,4 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, Base::buildMeshTopology(); } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/meshdistribution.h b/src/mesh/meshdistribution.h index 984182a89..211d4e0d1 100644 --- a/src/mesh/meshdistribution.h +++ b/src/mesh/meshdistribution.h @@ -13,13 +13,10 @@ #include "mpiutilities.h" #include "variables.h" -using namespace std; -using namespace geometry; - namespace meshing { template <typename _Mesh, typename _QC_Mesh, int DIM> void distributeMesh(_Mesh &_global_mesh, _QC_Mesh &_local_mesh, - const vector<int> &_material_idxs) { + const std::vector<int> &_material_idxs) { // Partitioning mesh int adj_edges = 0; int n_constraint = 1; @@ -28,16 +25,16 @@ void distributeMesh(_Mesh &_global_mesh, _QC_Mesh &_local_mesh, int n_parts = mpi_size; int options[3]; - vector<int> elements_of_ranks; - vector<int> nboel_tmp_i; - vector<int> nboel_tmp_v; - vector<int> vwgt; - vector<int> adjwgt; - vector<int> local_elements; - vector<int> el_part; + std::vector<int> elements_of_ranks; + std::vector<int> nboel_tmp_i; + std::vector<int> nboel_tmp_v; + std::vector<int> vwgt; + std::vector<int> adjwgt; + std::vector<int> local_elements; + std::vector<int> el_part; - vector<float> tpwgts; - vector<float> ubvec; + std::vector<float> tpwgts; + std::vector<float> ubvec; MPI_Comm mpi_comm; MPI_Comm_dup(MPI_COMM_WORLD, &mpi_comm); @@ -48,7 +45,7 @@ void distributeMesh(_Mesh &_global_mesh, _QC_Mesh &_local_mesh, nel_proc = elements_of_ranks[mpi_rank + 1] - elements_of_ranks[mpi_rank]; // this is a poor partition - adj_edges = buildParmetisGraph<pair<size_t, size_t>>( + adj_edges = buildParmetisGraph<std::pair<size_t, size_t>>( nboel_tmp_i, nboel_tmp_v, mpi_size, _global_mesh.faces_.size(), _global_mesh.if_boundary_faces_, _global_mesh.simplex_index_to_key_, @@ -85,14 +82,14 @@ void distributeMesh(_Mesh &_global_mesh, _QC_Mesh &_local_mesh, el_part.resize(nel_proc); if (mpi_rank == 0) - cout << " PARAMETIS OUTPUT " << endl; + std::cout << " PARAMETIS OUTPUT " << std::endl; ParMETIS_V3_PartKway(&elements_of_ranks[0], &nboel_tmp_i[0], &nboel_tmp_v[0], &vwgt[0], &adjwgt[0], &wgtflag, &numflag, &n_constraint, &n_parts, &tpwgts[0], &ubvec[0], options, &edgecut, &el_part[0], &mpi_comm); - vector<int> ranks_of_elements; + std::vector<int> ranks_of_elements; RedistributeGraph(elements_of_ranks, el_part, local_elements, ranks_of_elements, _global_mesh.meshCells_.size(), nel_proc, @@ -125,4 +122,4 @@ void distributeMesh(_Mesh &_global_mesh, _QC_Mesh &_local_mesh, // } // } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/metisutils.h b/src/mesh/metisutils.h index f35cf9015..9c62f1023 100644 --- a/src/mesh/metisutils.h +++ b/src/mesh/metisutils.h @@ -14,12 +14,9 @@ #include <iostream> #include <mpi.h> #include <stdio.h> -#include <string.h> #include <vector> -using namespace std; - -void calcUniformDist(vector<int> &x_dist, const int nx, const int ndist) { +void calcUniformDist(std::vector<int> &x_dist, const int nx, const int ndist) { x_dist[0] = 0; for (int id = 1; id <= ndist; id++) { x_dist[id] = (int)((double)id / (double)ndist * (double)nx + 0.5); @@ -27,10 +24,12 @@ void calcUniformDist(vector<int> &x_dist, const int nx, const int ndist) { } template <class MeshEdge> -int buildParmetisGraph(vector<int> &nboel_tmp_i, vector<int> &nboel_tmp_v, - int mpi_size, int n_faces, vector<bool> fa_flag, - const vector<size_t> &id_to_key, vector<int> elora, - int nel_proc, vector<MeshEdge> elofa, int mpi_rank) { +int buildParmetisGraph(std::vector<int> &nboel_tmp_i, + std::vector<int> &nboel_tmp_v, int mpi_size, int n_faces, + std::vector<bool> fa_flag, + const std::vector<size_t> &id_to_key, + std::vector<int> elora, int nel_proc, + std::vector<MeshEdge> elofa, int mpi_rank) { // assembling adjacency arrays for Metis partitioning // store el_ids neighbouring internal faces only @@ -198,15 +197,15 @@ int buildParmetisGraph(vector<int> &nboel_tmp_i, vector<int> &nboel_tmp_v, return temp_int; } -void RedistributeGraph(vector<int> elora, const vector<int> &el_part, - vector<int> &LOCAL_ELEMENTS, - vector<int> &RANKS_OF_ELEMENTS, int n_el, int &nel_proc, - int mpi_size, int mpi_rank) { +void RedistributeGraph(std::vector<int> elora, const std::vector<int> &el_part, + std::vector<int> &LOCAL_ELEMENTS, + std::vector<int> &RANKS_OF_ELEMENTS, int n_el, + int &nel_proc, int mpi_size, int mpi_rank) { int send_count; int *NofEL_OTHERS, *NofEL_ALL; - vector<int> send_buff, recv_buff, recv_count, recv_disp; + std::vector<int> send_buff, recv_buff, recv_count, recv_disp; send_buff = el_part; send_count = nel_proc; diff --git a/src/mesh/packNodalData.ipp b/src/mesh/packNodalData.ipp index c4faae1b5..8cdc866bb 100644 --- a/src/mesh/packNodalData.ipp +++ b/src/mesh/packNodalData.ipp @@ -8,6 +8,8 @@ \author P. Gupta */ +#pragma once +#include "qcMesh.h" namespace meshing { template <int D, int K, int NIDOF, typename repatomContainer, @@ -15,12 +17,12 @@ template <int D, int K, int NIDOF, typename repatomContainer, inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: packNodalDataAndTopology( - const unordered_map<size_t, int> &_remainingNodesMaterialIDs + const std::unordered_map<size_t, int> &_remainingNodesMaterialIDs #ifdef FINITE_TEMPERATURE , - const unordered_map<size_t, _thermal_point_> + const std::unordered_map<size_t, _thermal_point_> &_remainingNodesThermalDOFs, - const unordered_map<size_t, double> &_remainingNodesEntropies + const std::unordered_map<size_t, double> &_remainingNodesEntropies #endif , const bool &_build_node_adj, const bool &_build_face_adj, @@ -95,15 +97,15 @@ template <int D, int K, int NIDOF, typename repatomContainer, inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: packNodalDataAndTopology( - const unordered_map<size_t, double> &_remainingNodesWeights, - const unordered_map<size_t, int> &_remainingNodesFlags, - const unordered_map<size_t, int> &_remainingNodesMaterialIDs, - const vector<double> &_remainingCellWeights + const std::unordered_map<size_t, double> &_remainingNodesWeights, + const std::unordered_map<size_t, int> &_remainingNodesFlags, + const std::unordered_map<size_t, int> &_remainingNodesMaterialIDs, + const std::vector<double> &_remainingCellWeights #ifdef FINITE_TEMPERATURE , - const unordered_map<size_t, _thermal_point_> + const std::unordered_map<size_t, _thermal_point_> &_remainingNodesThermalDOFs, - const unordered_map<size_t, double> &_remainingNodesEntropies + const std::unordered_map<size_t, double> &_remainingNodesEntropies #endif , const bool &_build_node_adj, const bool &_build_face_adj, @@ -173,4 +175,4 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: } } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/qcEdgeRemoval.ipp b/src/mesh/qcEdgeRemoval.ipp index 5cf623774..ede75b11d 100644 --- a/src/mesh/qcEdgeRemoval.ipp +++ b/src/mesh/qcEdgeRemoval.ipp @@ -17,26 +17,27 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: reconnectElementsAroundEdge( const _edge_ &_edge, const edgeRemoval &_edgeEraser3D, - const vector<size_t> &_ringVertexIDs, - const vector<_node_> &_sourceToRingProjectors, + const std::vector<size_t> &_ringVertexIDs, + const std::vector<_node_> &_sourceToRingProjectors, const _node_ &_sourceToTargetProjector, const size_t &_source, const _node_ &_sourcePoint, const size_t &_target, - const _node_ &_targetPoint, const vector<_node_> &_ringVertices, - const int &_owner_rank, const vector<_pairKey_> &_elementsToBeRemoved, - unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, - unordered_map<size_t, _matrix_> &_newCellsBasis, - unordered_map<size_t, int> &_newCellsNVolume) { + const _node_ &_targetPoint, const std::vector<_node_> &_ringVertices, + const int &_owner_rank, + const std::vector<_pairKey_> &_elementsToBeRemoved, + std::unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, + std::unordered_map<size_t, _matrix_> &_newCellsBasis, + std::unordered_map<size_t, int> &_newCellsNVolume) { const int numberOfTriangles = _edgeEraser3D.getNumberOfTriangles(); - vector<_pairKey_> sourceTetra(numberOfTriangles), + std::vector<_pairKey_> sourceTetra(numberOfTriangles), targetTetra(numberOfTriangles); - array<int, K> ring_triangle; + std::array<int, K> ring_triangle; _simplexCell_ newCell; - array<_node_, K + 1> newCellNodes; - array<_node_, K> newCellProjectors; - array<_node_, K> newCellEdges; + std::array<_node_, K + 1> newCellNodes; + std::array<_node_, K> newCellProjectors; + std::array<_node_, K> newCellEdges; _matrix_ newCellBasis; int newCellNVolume; @@ -46,8 +47,8 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: newCell.resetNeighbours(); for (int d = 0; d < K; d++) { - newCell.setNode(make_pair(_owner_rank, _ringVertexIDs[ring_triangle[d]]), - d); + newCell.setNode( + std::make_pair(_owner_rank, _ringVertexIDs[ring_triangle[d]]), d); newCellProjectors[d] = _sourceToRingProjectors[ring_triangle[d]] - _sourceToTargetProjector; @@ -64,23 +65,23 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: _ringVertices[ring_triangle[d]] - _edgeEraser3D.getTarget(); } - newCell.setNode(make_pair(_owner_rank, _target), K); + newCell.setNode(std::make_pair(_owner_rank, _target), K); // cout<<"I was trying a new target cell "<<endl; getBasisFromProjectors<K>(newCellEdges, newCellProjectors, newCellBasis, newCellNVolume); - newCell.setPairKey(make_pair(_owner_rank, Base::newCellKey_)); - _elementsToBeInserted.insert(make_pair(Base::newCellKey_, newCell)); - _newCellsBasis.insert(make_pair(Base::newCellKey_, newCellBasis)); - _newCellsNVolume.insert(make_pair(Base::newCellKey_, newCellNVolume)); + newCell.setPairKey(std::make_pair(_owner_rank, Base::newCellKey_)); + _elementsToBeInserted.insert(std::make_pair(Base::newCellKey_, newCell)); + _newCellsBasis.insert(std::make_pair(Base::newCellKey_, newCellBasis)); + _newCellsNVolume.insert(std::make_pair(Base::newCellKey_, newCellNVolume)); - targetTetra[i] = make_pair(_owner_rank, Base::newCellKey_); + targetTetra[i] = std::make_pair(_owner_rank, Base::newCellKey_); ++Base::newCellKey_; - newCell.setNode(make_pair(_owner_rank, _source), 0); + newCell.setNode(std::make_pair(_owner_rank, _source), 0); for (int d = 0; d < K; d++) { - newCell.setNode(make_pair(_owner_rank, _ringVertexIDs[ring_triangle[d]]), - d + 1); + newCell.setNode( + std::make_pair(_owner_rank, _ringVertexIDs[ring_triangle[d]]), d + 1); newCellProjectors[d] = _sourceToRingProjectors[ring_triangle[d]]; @@ -96,12 +97,12 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: getBasisFromProjectors<K>(newCellEdges, newCellProjectors, newCellBasis, newCellNVolume); - newCell.setPairKey(make_pair(_owner_rank, Base::newCellKey_)); - _elementsToBeInserted.insert(make_pair(Base::newCellKey_, newCell)); - _newCellsBasis.insert(make_pair(Base::newCellKey_, newCellBasis)); - _newCellsNVolume.insert(make_pair(Base::newCellKey_, newCellNVolume)); + newCell.setPairKey(std::make_pair(_owner_rank, Base::newCellKey_)); + _elementsToBeInserted.insert(std::make_pair(Base::newCellKey_, newCell)); + _newCellsBasis.insert(std::make_pair(Base::newCellKey_, newCellBasis)); + _newCellsNVolume.insert(std::make_pair(Base::newCellKey_, newCellNVolume)); - sourceTetra[i] = make_pair(_owner_rank, Base::newCellKey_); + sourceTetra[i] = std::make_pair(_owner_rank, Base::newCellKey_); ++Base::newCellKey_; } @@ -235,16 +236,16 @@ inline bool KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: tryQCEdgeRemoval( const _edge_ &_edge, edgeRemoval &_edgeEraser3D, - vector<_pairKey_> &_elementsToBeRemoved, - unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, - unordered_map<size_t, _matrix_> &_newCellsBasis, - unordered_map<size_t, int> &_newCellsNVolume, bool print) { + std::vector<_pairKey_> &_elementsToBeRemoved, + std::unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, + std::unordered_map<size_t, _matrix_> &_newCellsBasis, + std::unordered_map<size_t, int> &_newCellsNVolume, bool print) { bool removedEdge = false; bool isEdgeOnBoundary; _node_ sourceToTargetProjector; - vector<_node_> ringVertices; - vector<_node_> sourceToRingProjectors; - vector<size_t> ringVertexIDs; + std::vector<_node_> ringVertices; + std::vector<_node_> sourceToRingProjectors; + std::vector<size_t> ringVertexIDs; const size_t source = Base::getSimplexNodeKey(_edge.first, _edge.second); const size_t target = Base::getSimplexNodeKey(_edge.first, _edge.third); @@ -305,16 +306,16 @@ inline bool KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: tryQCEdgeRemovalDependent( const int &_taskRank, const _edge_ &_edge, edgeRemoval &_edgeEraser3D, - vector<_pairKey_> &_elementsToBeRemoved, - unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, - unordered_map<size_t, _matrix_> &_newCellsBasis, - unordered_map<size_t, int> &_newCellsNVolume, - unordered_map<size_t, _simplexNode_> &_nodesToBeInserted, + std::vector<_pairKey_> &_elementsToBeRemoved, + std::unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, + std::unordered_map<size_t, _matrix_> &_newCellsBasis, + std::unordered_map<size_t, int> &_newCellsNVolume, + std::unordered_map<size_t, _simplexNode_> &_nodesToBeInserted, #ifdef FINITE_TEMPERATURE - unordered_map<size_t, _thermal_point_> &_thermalPointsToBeInserted, - unordered_map<size_t, double> &_thermalPointEntropyToBeInserted, + std::unordered_map<size_t, _thermal_point_> &_thermalPointsToBeInserted, + std::unordered_map<size_t, double> &_thermalPointEntropyToBeInserted, #endif - unordered_map<size_t, int> &_materialIndexToBeInserted, + std::unordered_map<size_t, int> &_materialIndexToBeInserted, const size_t &key, const int &iter, bool forceReplace, bool print) { bool removedEdge = false; @@ -325,23 +326,23 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: int localIndex; size_t noofElementsToBeRemoved; - array<size_t, 4> adjacencySizesAndFixedPointIds; - array<double, 2 * D> eraserPointsAndChecks; + std::array<size_t, 4> adjacencySizesAndFixedPointIds; + std::array<double, 2 * D> eraserPointsAndChecks; - vector<_node_> ringVertices; - vector<size_t> ringVertexIDs; - vector<_node_> sourceToRingProjectors; + std::vector<_node_> ringVertices; + std::vector<size_t> ringVertexIDs; + std::vector<_node_> sourceToRingProjectors; _node_ sourceToTargetProjector; size_t source, target; _node_ sourcePoint, targetPoint; - vector<int> nodeMaterialIndices; + std::vector<int> nodeMaterialIndices; #ifdef FINITE_TEMPERATURE - vector<_thermal_point_> nodeThermalCoords; - vector<double> nodeEntropies; + std::vector<_thermal_point_> nodeThermalCoords; + std::vector<double> nodeEntropies; #endif - vector<size_t> adjacentElementKeysExc; + std::vector<size_t> adjacentElementKeysExc; bool deleteSingleElement; // other ranks only need to delete some elements @@ -422,7 +423,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // if(Base::meshCells_.find(neighbourKey.second)!=Base::meshCells_.end()) // { // Base::meshCells_.at(neighbourKey.second).setNeighbour( - // make_pair(-1, + // std::make_pair(-1, // numeric_limits<size_t>::max()), nid); // } // else @@ -430,7 +431,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // assert(Base::halo_mesh_simplices_.find(neighbourKey.second) // != Base::halo_mesh_simplices_.end()); // Base::halo_mesh_simplices_.at(neighbourKey.second).setNeighbour( - // make_pair(-1, + // std::make_pair(-1, // numeric_limits<size_t>::max()), nid); // } // } @@ -465,9 +466,9 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // , "<< edgeRemovalSolve<<" , "<<volumeIncidentElements<<" , // "<<_edgeEraser3D.computeReconnectedVolume()<<endl; - // unordered_map<size_t, _ind_simplex_> outputTets; - // unordered_map<size_t, _node_> outputNodes; - // unordered_map<size_t, int> ranksOutputTets; + // std::unordered_map<size_t, _ind_simplex_> outputTets; + // std::unordered_map<size_t, _node_> outputNodes; + // std::unordered_map<size_t, int> ranksOutputTets; // Base::getSimplicesFromCells(_elementsToBeRemoved.begin(), // _elementsToBeRemoved.end(), outputTets, @@ -640,19 +641,19 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: _simplexNode_ newNode; for (int i = 0; i < ringVertices.size(); i++) { - newNode.setPairKey(make_pair(_taskRank, ringVertexIDs[i])); + newNode.setPairKey(std::make_pair(_taskRank, ringVertexIDs[i])); newNode.setPoint(ringVertices[i]); - _nodesToBeInserted.insert(make_pair(ringVertexIDs[i], newNode)); + _nodesToBeInserted.insert(std::make_pair(ringVertexIDs[i], newNode)); _materialIndexToBeInserted.insert( - make_pair(ringVertexIDs[i], nodeMaterialIndices[i])); + std::make_pair(ringVertexIDs[i], nodeMaterialIndices[i])); #ifdef FINITE_TEMPERATURE _thermalPointsToBeInserted.insert( - make_pair(ringVertexIDs[i], nodeThermalCoords[i])); + std::make_pair(ringVertexIDs[i], nodeThermalCoords[i])); _thermalPointEntropyToBeInserted.insert( - make_pair(ringVertexIDs[i], nodeEntropies[i])); + std::make_pair(ringVertexIDs[i], nodeEntropies[i])); #endif } } else { diff --git a/src/mesh/qcFaceRemoval.ipp b/src/mesh/qcFaceRemoval.ipp index ad9194efd..a56116d91 100644 --- a/src/mesh/qcFaceRemoval.ipp +++ b/src/mesh/qcFaceRemoval.ipp @@ -11,11 +11,11 @@ inline bool KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: tryQCFaceRemoval( const _face_ &_face, faceRemoval &_faceEraser3D, - vector<_pairKey_> &_elementsToBeRemoved, - unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, - unordered_map<size_t, _matrix_> &_newCellsBasis, - unordered_map<size_t, int> &_newCellsNVolume, - unordered_map<size_t, _simplexNode_> &_nodesToBeInserted) { + std::vector<_pairKey_> &_elementsToBeRemoved, + std::unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, + std::unordered_map<size_t, _matrix_> &_newCellsBasis, + std::unordered_map<size_t, int> &_newCellsNVolume, + std::unordered_map<size_t, _simplexNode_> &_nodesToBeInserted) { bool removedFace = false; const _pairKey_ faceNeighbour = @@ -35,14 +35,14 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: _faceEraser3D.setSource(sourcePoint); _faceEraser3D.setTarget(targetPoint); - array<_node_, 3> faceNodes; - array<size_t, 3> faceNodeKeys; + std::array<_node_, 3> faceNodes; + std::array<size_t, 3> faceNodeKeys; // if any of the edges of the face has three incident elements, // then lets not remove this face. _edge_ e; e.first = _face.first; - vector<_pairKey_> incidentCells; + std::vector<_pairKey_> incidentCells; bool onBoundary; // return false if any edge of the face has 3 incident elements @@ -89,15 +89,15 @@ inline bool KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: tryQCFaceRemovalDependent( const int &_task_rank, const _face_ &_face, faceRemoval &_faceEraser3D, - vector<_pairKey_> &_elementsToBeRemoved, - unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, - unordered_map<size_t, _matrix_> &_newCellsBasis, - unordered_map<size_t, int> &_newCellsNVolume, - unordered_map<size_t, _simplexNode_> &_nodesToBeInserted) { + std::vector<_pairKey_> &_elementsToBeRemoved, + std::unordered_map<size_t, _simplexCell_> &_elementsToBeInserted, + std::unordered_map<size_t, _matrix_> &_newCellsBasis, + std::unordered_map<size_t, int> &_newCellsNVolume, + std::unordered_map<size_t, _simplexNode_> &_nodesToBeInserted) { bool swapPossible = false; - vector<_face_> treeFaces; - vector<_node_> treeNodes; + std::vector<_face_> treeFaces; + std::vector<_node_> treeNodes; if (mpi_rank == _task_rank) { // get all incident elements and all three edges @@ -106,4 +106,4 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: back_inserter(treeNodes)); } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/qcMesh.h b/src/mesh/qcMesh.h index 8f5d42039..e9c5001eb 100644 --- a/src/mesh/qcMesh.h +++ b/src/mesh/qcMesh.h @@ -1,34 +1,35 @@ #pragma once +#include "Euclidean.h" #include "mesh.h" namespace meshing { template <int D, int K, int NIDOF> struct InterProcMeshData { public: typedef point<D> _node_; - typedef array<_node_, K + 1> _simplex_; - typedef array<size_t, K + 1> _ind_simplex_; + typedef std::array<_node_, K + 1> _simplex_; + typedef std::array<size_t, K + 1> _ind_simplex_; typedef Eigen::Matrix<double, K, K> _matrix_; typedef point<NIDOF> _thermal_point_; public: - vector<vector<bool>> overlap_simplex_idxs_sent_flag_; - vector<vector<int>> overlap_simplex_idxs_; - // vector<set<int>> overlap_node_idxs_; - vector<vector<int>> overlap_node_idxs_; + std::vector<std::vector<bool>> overlap_simplex_idxs_sent_flag_; + std::vector<std::vector<int>> overlap_simplex_idxs_; + // std::vector<set<int>> overlap_node_idxs_; + std::vector<std::vector<int>> overlap_node_idxs_; // received nodes and simplices from other ranks. // to get neighbourhoods across processors - vector<vector<_node_>> overlapping_nodes_recv_; - vector<vector<_ind_simplex_>> overlapping_simplices_recv_; - vector<vector<_matrix_>> overlapping_element_lattice_vectors_recv_; - vector<vector<bool>> overlapping_simplices_recv_atomistic_flag_; + std::vector<std::vector<_node_>> overlapping_nodes_recv_; + std::vector<std::vector<_ind_simplex_>> overlapping_simplices_recv_; + std::vector<std::vector<_matrix_>> overlapping_element_lattice_vectors_recv_; + std::vector<std::vector<bool>> overlapping_simplices_recv_atomistic_flag_; #ifdef FINITE_TEMPERATURE - vector<vector<_thermal_point_>> overlapping_thermal_dofs_recv_; + std::vector<std::vector<_thermal_point_>> overlapping_thermal_dofs_recv_; #endif // we will try google maps later on - vector<unordered_map<int, int>> overlap_nodes_sent_idx_recv_side_; + std::vector<std::unordered_map<int, int>> overlap_nodes_sent_idx_recv_side_; }; // this is a mesh specific to QC. @@ -53,8 +54,8 @@ public: typedef typename Base::_vidx_face_ _vidx_face_; typedef typename Base::_face_ _face_; typedef Eigen::Matrix<double, K, K> _matrix_; - typedef array<double, K * K> _stl_matrix_; - typedef pair<int, int> _overlap_index_; + typedef std::array<double, K * K> _stl_matrix_; + typedef std::pair<int, int> _overlap_index_; typedef point<NIDOF> _thermal_point_; typedef typename Base::_simplexCell_ _simplexCell_; @@ -65,31 +66,31 @@ public: public: // relevant materials - vector<Material *> qcMaterials_; + std::vector<Material *> qcMaterials_; // QC specific quantites to be stored for a mesh - vector<double> element_volumes_; - vector<double> element_qualities_; - vector<bool> element_near_boundary_flag_; - vector<bool> element_atomistic_flag_; - vector<bool> element_monolattice_flag_; + std::vector<double> element_volumes_; + std::vector<double> element_qualities_; + std::vector<bool> element_near_boundary_flag_; + std::vector<bool> element_atomistic_flag_; + std::vector<bool> element_monolattice_flag_; // these stay constant unless an element is flipped. // No need to store lattice generators. Compute when needed - // vector<array<int, 2*K>> element_lattice_generators_; + // std::vector<std::array<int, 2*K>> element_lattice_generators_; #ifdef DISPLAY_ELEMENT_MARKERS - vector<int> element_markers_; + std::vector<int> element_markers_; #endif - vector<int> material_idx_of_nodes_; - vector<int> material_idx_of_simplices_; - vector<int> sampling_atoms_of_simplices_; + std::vector<int> material_idx_of_nodes_; + std::vector<int> material_idx_of_simplices_; + std::vector<int> sampling_atoms_of_simplices_; - vector<double> element_jacobians_; - vector<double> element_densities_; + std::vector<double> element_jacobians_; + std::vector<double> element_densities_; // element lattice vectors - vector<_matrix_> element_lattice_vectors_; + std::vector<_matrix_> element_lattice_vectors_; InterProcMeshData<D, K, NIDOF> overlappingMeshData; @@ -100,19 +101,19 @@ public: // // neighbourhood calculations. // // vector of overlapping simplices with each rank. // // So that we know which simplices are sharing information - // vector<vector<bool>> overlap_simplex_idxs_sent_flag_; - // vector<vector<int>> overlap_simplex_idxs_; - // // vector<set<int>> overlap_node_idxs_; - // vector<vector<int>> overlap_node_idxs_; + // std::vector<std::vector<bool>> overlap_simplex_idxs_sent_flag_; + // std::vector<std::vector<int>> overlap_simplex_idxs_; + // // std::vector<set<int>> overlap_node_idxs_; + // std::vector<std::vector<int>> overlap_node_idxs_; // // received nodes and simplices from other ranks. // // to get neighbourhoods across processors - // vector<vector<_node_>> overlapping_nodes_recv_; - // vector<vector<_ind_simplex_>> overlapping_simplices_recv_; - // vector<vector<_matrix_>> + // std::vector<std::vector<_node_>> overlapping_nodes_recv_; + // std::vector<std::vector<_ind_simplex_>> overlapping_simplices_recv_; + // std::vector<std::vector<_matrix_>> // overlapping_element_lattice_vectors_recv_; - // vector<vector<bool>> overlapping_simplices_recv_atomistic_flag_; #ifdef - // FINITE_TEMPERATURE vector<vector<_thermal_point_>> + // std::vector<std::vector<bool>> overlapping_simplices_recv_atomistic_flag_; #ifdef + // FINITE_TEMPERATURE std::vector<std::vector<_thermal_point_>> // overlapping_thermal_dofs_recv_; #endif /* * We should just make elementDataContainer and nodeDataContainer @@ -121,15 +122,15 @@ public: repatomContainer repatoms; samplingAtomContainer samplingAtoms; - unordered_map<size_t, size_t> cellKeyToCentralSamplingAtom_; + std::unordered_map<size_t, size_t> cellKeyToCentralSamplingAtom_; // received nodes and cells from other ranks for mesh repair - unordered_map<size_t, _matrix_> haloCellsBasis_; + std::unordered_map<size_t, _matrix_> haloCellsBasis_; #ifdef FINITE_TEMPERATURE - unordered_map<size_t, double> haloNodeEntropy_; - unordered_map<size_t, _thermal_point_> haloNodeThermalPoints_; + std::unordered_map<size_t, double> haloNodeEntropy_; + std::unordered_map<size_t, _thermal_point_> haloNodeThermalPoints_; #endif - unordered_map<size_t, int> haloNodeMaterialIndices_; + std::unordered_map<size_t, int> haloNodeMaterialIndices_; // atomistic domains inside the mesh Box<point<D>, D> atomisticDomain_; @@ -143,13 +144,13 @@ public: element_jacobians_(), repatoms(), samplingAtoms(), cellKeyToCentralSamplingAtom_(), atomisticDomain_() {} - void assignMaterials(const vector<Material *> &_m) { qcMaterials_ = _m; } + void assignMaterials(const std::vector<Material *> &_m) { qcMaterials_ = _m; } _node_ getNode(const size_t &_id) const { return Base::nodes_[_id]; } template <typename ContainerType> _node_ getOverlappingMeshPoint(const ContainerType &_overlapContainer, - const pair<int, size_t> &_id) const { + const std::pair<int, size_t> &_id) const { assert((_id.first < _overlapContainer.overlapping_nodes_recv_.size()) && (_id.second < _overlapContainer.overlapping_nodes_recv_[_id.first].size())); @@ -167,9 +168,10 @@ public: } #endif - void build(const vector<size_t> &_nodeIds, const vector<_node_> &_nodes, - const vector<_ind_simplex_> &_elements, - const vector<int> &_materialIds) { + void build(const std::vector<size_t> &_nodeIds, + const std::vector<_node_> &_nodes, + const std::vector<_ind_simplex_> &_elements, + const std::vector<int> &_materialIds) { material_idx_of_nodes_.clear(); Base::meshCells_.reserve(_elements.size()); @@ -180,21 +182,21 @@ public: _simplexNode_ node; _simplexCell_ cell; - unordered_map<size_t, int> materialIDs; + std::unordered_map<size_t, int> materialIDs; for (size_t i_nd = 0; i_nd < _nodes.size(); i_nd++) { // indices and keys are same while building from vectors - Base::meshNodes_.insert(make_pair( + Base::meshNodes_.insert(std::make_pair( _nodeIds[i_nd], node.setNode(_nodes[i_nd], _nodeIds[i_nd]))); - materialIDs.insert(make_pair(_nodeIds[i_nd], _materialIds[i_nd])); + materialIDs.insert(std::make_pair(_nodeIds[i_nd], _materialIds[i_nd])); } for (size_t i_el = 0; i_el < _elements.size(); i_el++) { // indices and keys are same initially so we can relax about ordering // of any cell data that exists before building Base::meshCells_.insert( - make_pair(i_el, cell.setCell(_elements[i_el], i_el))); + std::make_pair(i_el, cell.setCell(_elements[i_el], i_el))); } Base::buildIndexKeyMaps(); @@ -216,12 +218,13 @@ public: #endif } - void build(const vector<size_t> &_nodeIds, const vector<_node_> &_nodes, - const vector<_ind_simplex_> &_elements, - const vector<int> &_materialIds, - vector<_stl_matrix_> &_element_basis, - const vector<double> &_element_densities, - const vector<double> &_element_jacobians) { + void build(const std::vector<size_t> &_nodeIds, + const std::vector<_node_> &_nodes, + const std::vector<_ind_simplex_> &_elements, + const std::vector<int> &_materialIds, + std::vector<_stl_matrix_> &_element_basis, + const std::vector<double> &_element_densities, + const std::vector<double> &_element_jacobians) { build(_nodeIds, _nodes, _elements, _materialIds); element_lattice_vectors_.clear(); @@ -252,7 +255,7 @@ public: element_volumes_.resize(Base::meshCells_.size()); element_qualities_.resize(Base::meshCells_.size()); sampling_atoms_of_simplices_.resize(Base::meshCells_.size(), - numeric_limits<int>::max()); + std::numeric_limits<int>::max()); #ifdef DISPLAY_ELEMENT_MARKERS element_markers_.resize(Base::meshCells_.size(), 0); @@ -267,9 +270,10 @@ public: Base::vertex_adj_.clear(); } - void buildSubMeshFromSubset(const vector<int> &, const vector<int> &, - const vector<int> &, const int &, const int &, - const Base &); + void buildSubMeshFromSubset(const std::vector<int> &, + const std::vector<int> &, + const std::vector<int> &, const int &, + const int &, const Base &); // ! repair dependent mesh cells void meshRepairDependent(); @@ -308,7 +312,7 @@ public: element_monolattice_flag_.reserve(Base::meshCells_.size()); - array<int, K + 1> array_material_idxs; + std::array<int, K + 1> array_material_idxs; size_t nodeKey; @@ -322,8 +326,8 @@ public: material_idx_of_nodes_[Base::meshNodes_.at(nodeKey).getMeshIndex()]; } - if (count(array_material_idxs.begin(), array_material_idxs.end(), - array_material_idxs[0]) != K + 1) { + if (std::count(array_material_idxs.begin(), array_material_idxs.end(), + array_material_idxs[0]) != K + 1) { mono_flag = false; cout << i << ", detected a multi-lattice element. Just warning .... " << "rank : " << mpi_rank << endl; @@ -335,7 +339,7 @@ public: } } - void initializeBravaisLattice(vector<_stl_matrix_> &_lattice_vectors) { + void initializeBravaisLattice(std::vector<_stl_matrix_> &_lattice_vectors) { assignMonoLatticeFlag(); assert(_lattice_vectors.size() == Base::meshCells_.size()); @@ -368,7 +372,7 @@ public: } } - void initializeBravaisLattice(const vector<material<D> *> &_materials) { + void initializeBravaisLattice(const std::vector<material<D> *> &_materials) { assignMonoLatticeFlag(); @@ -416,7 +420,7 @@ public: } void initializeBravaisLattice(const Box<point<D>, D> &_atomistic_box, - const vector<material<D> *> &_materials) { + const std::vector<material<D> *> &_materials) { assignMonoLatticeFlag(); element_lattice_vectors_.clear(); @@ -437,9 +441,9 @@ public: _matrix_ materialBasis; _matrix_ initialDeformation; - array<_node_, K> edges, materialBasesStl; + std::array<_node_, K> edges, materialBasesStl; - array<int, K> edgesOrder; + std::array<int, K> edgesOrder; for (size_t i = 0; i != Base::meshCells_.size(); i++) { centroid.fill(0.0); @@ -563,11 +567,11 @@ public: void initializeElementsAtomisticFlag() { _matrix_ edges; - array<_node_, K + 1> simplex; + std::array<_node_, K + 1> simplex; Eigen::Matrix<int, K, K> lattice_index_mat; Eigen::VectorXi lattice_sites_upper_bound(K); Eigen::VectorXi lattice_sites_lower_bound(K); - array<int, 2 * K> simplex_lattice_generator; + std::array<int, 2 * K> simplex_lattice_generator; element_atomistic_flag_.clear(); int n_space_det; @@ -645,7 +649,7 @@ public: } } - void initializeElementsAtomisticFlag(const vector<int> &_flags) { + void initializeElementsAtomisticFlag(const std::vector<int> &_flags) { element_atomistic_flag_.clear(); element_atomistic_flag_.reserve(Base::meshCells_.size()); @@ -672,14 +676,15 @@ public: element_qualities_.resize(Base::meshCells_.size()); element_densities_.resize(Base::meshCells_.size()); sampling_atoms_of_simplices_.resize(Base::meshCells_.size(), - numeric_limits<int>::max()); + std::numeric_limits<int>::max()); #ifdef DISPLAY_ELEMENT_MARKERS element_markers_.resize(Base::meshCells_.size(), 0); #endif } - void initializeElementDensities(const vector<material<D> *> &_materials) { + void + initializeElementDensities(const std::vector<material<D> *> &_materials) { size_t cellKey, nodeKey, material_idx; for (size_t i = 0; i < Base::simplex_index_to_key_.size(); i++) { element_densities_[i] = 0.0; @@ -697,7 +702,7 @@ public: } void updateElements() { - array<_node_, K + 1> simplex; + std::array<_node_, K + 1> simplex; for (size_t i = 0; i != Base::meshCells_.size(); i++) { Base::getSimplex(Base::meshCells_.at(Base::simplex_index_to_key_[i]), @@ -729,7 +734,7 @@ public: } void volume(double &_mesh_volume) { - array<_node_, K + 1> simplex; + std::array<_node_, K + 1> simplex; _mesh_volume = 0.0; double local_volume = 0.0; @@ -747,11 +752,11 @@ public: } void buildRepatoms( - const unordered_map<size_t, int> &_elementNodeFlags + const std::unordered_map<size_t, int> &_elementNodeFlags #ifdef FINITE_TEMPERATURE , - const unordered_map<size_t, _thermal_point_> &_initialthermalPoints, - const unordered_map<size_t, double> &_initialEntropies + const std::unordered_map<size_t, _thermal_point_> &_initialthermalPoints, + const std::unordered_map<size_t, double> &_initialEntropies #endif ) { // build repatoms. @@ -802,8 +807,8 @@ public: } _simplex_ simplex; - array<double, K + 1> angles; - array<double, K + 1> node_volumes; + std::array<double, K + 1> angles; + std::array<double, K + 1> node_volumes; _node_ simplexBaryCenter; #ifdef FINITE_TEMPERATURE @@ -862,8 +867,9 @@ public: simplexBaryCenter += simplex[d] / double(K + 1); - r_cut = max(r_cut, qcMaterials_[material_idx_of_nodes_[nodeIndex]] - ->getNeighborInteractionCutoffRadius()); + r_cut = + std::max(r_cut, qcMaterials_[material_idx_of_nodes_[nodeIndex]] + ->getNeighborInteractionCutoffRadius()); #ifdef FINITE_TEMPERATURE centralSamplingAtomThermalDOF += @@ -883,8 +889,8 @@ public: samplingAtoms.centralIDOFs_.push_back(centralSamplingAtomThermalDOF); #endif - cellKeyToCentralSamplingAtom_.insert( - make_pair(cellKey, samplingAtoms.centralLocations_.size() - 1)); + cellKeyToCentralSamplingAtom_.insert(std::make_pair( + cellKey, samplingAtoms.centralLocations_.size() - 1)); // add material ids of sampling atoms here. // for now adding only last node's material index @@ -933,9 +939,9 @@ public: samplingAtoms.centralLocations_.size()); } - void - buildSamplingAtoms(const vector<double> &_elementWeights, - const unordered_map<size_t, double> &_elementNodeWeights) { + void buildSamplingAtoms( + const std::vector<double> &_elementWeights, + const std::unordered_map<size_t, double> &_elementNodeWeights) { samplingAtoms.clear(); samplingAtoms.resizeNodalSamplingAtoms(Base::meshNodes_.size()); @@ -986,8 +992,9 @@ public: simplexBaryCenter += simplex[d] / double(K + 1); - r_cut = max(r_cut, qcMaterials_[material_idx_of_nodes_[nodeIndex]] - ->getNeighborInteractionCutoffRadius()); + r_cut = + std::max(r_cut, qcMaterials_[material_idx_of_nodes_[nodeIndex]] + ->getNeighborInteractionCutoffRadius()); #ifdef FINITE_TEMPERATURE centralSamplingAtomThermalDOF += @@ -1007,8 +1014,8 @@ public: samplingAtoms.centralIDOFs_.push_back(centralSamplingAtomThermalDOF); #endif - cellKeyToCentralSamplingAtom_.insert( - make_pair(cellKey, samplingAtoms.centralLocations_.size() - 1)); + cellKeyToCentralSamplingAtom_.insert(std::make_pair( + cellKey, samplingAtoms.centralLocations_.size() - 1)); // add material ids of sampling atoms here. // for now adding only last node's material index @@ -1088,8 +1095,8 @@ public: size_t centralIndex, cellKey, nodeIndex; _simplex_ simplex; - array<double, K + 1> angles; - array<double, K + 1> node_volumes; + std::array<double, K + 1> angles; + std::array<double, K + 1> node_volumes; double element_volume, element_density, element_jacobian, node_radius, side_radius, barycenter_volume, total_angles, barycenter_weight; @@ -1203,7 +1210,7 @@ public: // } void computeNodalCentroSymmetry() { - vector<_node_> latticeSymmetries; + std::vector<_node_> latticeSymmetries; fill(samplingAtoms.nodalCentroSymmetry_.begin(), samplingAtoms.nodalCentroSymmetry_.end(), 0.0); @@ -1222,7 +1229,7 @@ public: } template <typename ValueType> - void exchangeNodalValues(vector<ValueType> &_nodal_values) { + void exchangeNodalValues(std::vector<ValueType> &_nodal_values) { // get local representation VecGhostGetLocalForm(Base::distributedNodalDataPetsc_, &(Base::localNodaldataPetsc_)); @@ -1309,8 +1316,8 @@ public: // void exchangeWeights(ContainerType &_container) // { // // need correct InterprocConnectivity - // vector<vector<double>> weights_send(Base::connected_node_procs_.size()); - // vector<vector<double>> weights_recv(Base::connected_node_procs_.size()); + // std::vector<std::vector<double>> weights_send(Base::connected_node_procs_.size()); + // std::vector<std::vector<double>> weights_recv(Base::connected_node_procs_.size()); // for(int i_proc=0; i_proc<Base::connected_node_procs_.size(); i_proc++) // { @@ -1343,7 +1350,7 @@ public: // } template <typename inputIt> void eraseCells(inputIt begin, inputIt end) { - vector<size_t> indicesToDelete; + std::vector<size_t> indicesToDelete; for (inputIt It = begin; It != end; ++It) { if (Base::meshCells_.find((*It).second) != Base::meshCells_.end()) { @@ -1396,7 +1403,7 @@ public: } template <typename inputIt> void eraseCellsTrial(inputIt begin, inputIt end) { - vector<size_t> indicesToDelete; + std::vector<size_t> indicesToDelete; for (inputIt It = begin; It != end; ++It) { if (Base::meshCells_.find((*It).second) != Base::meshCells_.end()) { @@ -1445,8 +1452,8 @@ public: template <typename inputItCell> void insertCells(inputItCell cellsBegin, inputItCell cellsEnd, - const unordered_map<size_t, _matrix_> &newCellsBasis, - const unordered_map<size_t, int> &newCellsNV, + const std::unordered_map<size_t, _matrix_> &newCellsBasis, + const std::unordered_map<size_t, int> &newCellsNV, bool print = false) { size_t cellKey; double undeformedDensity, jacobian; @@ -1479,8 +1486,8 @@ public: assert(Base::halo_mesh_nodes_.find(newNodeKey) != Base::halo_mesh_nodes_.end()); - Base::meshNodes_.insert( - make_pair(newNodeKey, Base::halo_mesh_nodes_.at(newNodeKey))); + Base::meshNodes_.insert(std::make_pair( + newNodeKey, Base::halo_mesh_nodes_.at(newNodeKey))); // add key to node_index_to_key_ Base::node_index_to_key_.push_back(newNodeKey); @@ -1571,13 +1578,13 @@ public: template <typename inputItCell> void insertHaloCells( inputItCell cellsBegin, inputItCell cellsEnd, - const unordered_map<size_t, _matrix_> &_newCellsBasis, - const unordered_map<size_t, _simplexNode_> &_newNodes, - const unordered_map<size_t, int> &_newMaterialIndices + const std::unordered_map<size_t, _matrix_> &_newCellsBasis, + const std::unordered_map<size_t, _simplexNode_> &_newNodes, + const std::unordered_map<size_t, int> &_newMaterialIndices #ifdef FINITE_TEMPERATURE , - const unordered_map<size_t, _thermal_point_> &_newThermalPoints, - const unordered_map<size_t, double> &_newEntropies + const std::unordered_map<size_t, _thermal_point_> &_newThermalPoints, + const std::unordered_map<size_t, double> &_newEntropies #endif ) { size_t cellKey, nodeKey; @@ -1598,21 +1605,21 @@ public: if (Base::halo_mesh_nodes_.find(nodeKey) == Base::halo_mesh_nodes_.end()) { Base::halo_mesh_nodes_.insert( - make_pair(nodeKey, _newNodes.at(nodeKey))); + std::make_pair(nodeKey, _newNodes.at(nodeKey))); haloNodeMaterialIndices_.insert( - make_pair(nodeKey, _newMaterialIndices.at(nodeKey))); + std::make_pair(nodeKey, _newMaterialIndices.at(nodeKey))); #ifdef FINITE_TEMPERATURE haloNodeThermalPoints_.insert( - make_pair(nodeKey, _newThermalPoints.at(nodeKey))); + std::make_pair(nodeKey, _newThermalPoints.at(nodeKey))); haloNodeEntropy_.insert( - make_pair(nodeKey, _newEntropies.at(nodeKey))); + std::make_pair(nodeKey, _newEntropies.at(nodeKey))); #endif } } else { // this is important because we might need this cell again. - It->second.setNode(make_pair(mpi_rank, nodeKey), d); + It->second.setNode(std::make_pair(mpi_rank, nodeKey), d); } } @@ -1620,7 +1627,8 @@ public: Base::halo_mesh_simplices_.insert(*It); - haloCellsBasis_.insert(make_pair(cellKey, _newCellsBasis.at(cellKey))); + haloCellsBasis_.insert( + std::make_pair(cellKey, _newCellsBasis.at(cellKey))); } } @@ -1662,10 +1670,10 @@ public: template <typename ContainerType> void exchangeOverlapContainers(ContainerType &_overlapContainer) { - vector<vector<double>> overlapping_double_send(mpi_size); - vector<vector<double>> overlapping_double_recv(mpi_size); + std::vector<std::vector<double>> overlapping_double_send(mpi_size); + std::vector<std::vector<double>> overlapping_double_recv(mpi_size); - array<double, DIM> meshPoint; + std::array<double, DIM> meshPoint; for (int i_proc = 0; i_proc < mpi_size; i_proc++) { if (i_proc != mpi_rank) { @@ -1757,8 +1765,9 @@ public: template <typename OutputIterator> bool getIncidentCellsInOrder(const _edge_ &_edge, const size_t &, const size_t &, const _node_ &, const _node_ &, - OutputIterator output, vector<_node_> &, - vector<size_t> &, vector<_node_> &, _node_ &); + OutputIterator output, std::vector<_node_> &, + std::vector<size_t> &, std::vector<_node_> &, + _node_ &); void getEdgeProjector(const _pairKey_ &incident_simplex, const size_t &_node_a, const size_t &_node_b, @@ -1772,75 +1781,78 @@ public: void trimBoundaryElements(); template <typename edgeRemoval> - void reconnectElementsAroundEdge( - const _edge_ &, const edgeRemoval &, const vector<size_t> &, - const vector<_node_> &, const _node_ &, const size_t &, const _node_ &, - const size_t &, const _node_ &, const vector<_node_> &, const int &, - const vector<_pairKey_> &, unordered_map<size_t, _simplexCell_> &, - unordered_map<size_t, _matrix_> &, unordered_map<size_t, int> &); + void reconnectElementsAroundEdge(const _edge_ &, const edgeRemoval &, + const std::vector<size_t> &, + const std::vector<_node_> &, const _node_ &, + const size_t &, const _node_ &, + const size_t &, const _node_ &, + const std::vector<_node_> &, const int &, + const std::vector<_pairKey_> &, + std::unordered_map<size_t, _simplexCell_> &, + std::unordered_map<size_t, _matrix_> &, + std::unordered_map<size_t, int> &); // ! interproc face removal template <typename faceRemoval> - bool - tryQCFaceRemoval(const _face_ &, faceRemoval &, - vector<_pairKey_> &_outputKeys, - unordered_map<size_t, _simplexCell_> &_outputCells, - unordered_map<size_t, _matrix_> &_outputCellsBasis, - unordered_map<size_t, int> &_outputCellsNV, - unordered_map<size_t, _simplexNode_> &_nodesToBeInserted); + bool tryQCFaceRemoval( + const _face_ &, faceRemoval &, std::vector<_pairKey_> &_outputKeys, + std::unordered_map<size_t, _simplexCell_> &_outputCells, + std::unordered_map<size_t, _matrix_> &_outputCellsBasis, + std::unordered_map<size_t, int> &_outputCellsNV, + std::unordered_map<size_t, _simplexNode_> &_nodesToBeInserted); // ! local edge removal template <typename edgeRemoval> bool tryQCEdgeRemoval(const _edge_ &, edgeRemoval &, - vector<_pairKey_> &_outputKeys, - unordered_map<size_t, _simplexCell_> &_outputCells, - unordered_map<size_t, _matrix_> &_outputCellsBasis, - unordered_map<size_t, int> &_outputCellsNV, + std::vector<_pairKey_> &_outputKeys, + std::unordered_map<size_t, _simplexCell_> &_outputCells, + std::unordered_map<size_t, _matrix_> &_outputCellsBasis, + std::unordered_map<size_t, int> &_outputCellsNV, bool print = false); // ! interproc edge removal template <typename edgeRemoval> bool tryQCEdgeRemovalDependent( const int &, const _edge_ &, edgeRemoval &, - vector<_pairKey_> &_outputKeys, - unordered_map<size_t, _simplexCell_> &_outputCells, - unordered_map<size_t, _matrix_> &_outputCellsBasis, - unordered_map<size_t, int> &_outputCellsNV, - unordered_map<size_t, _simplexNode_> &_nodesToBeInserted, + std::vector<_pairKey_> &_outputKeys, + std::unordered_map<size_t, _simplexCell_> &_outputCells, + std::unordered_map<size_t, _matrix_> &_outputCellsBasis, + std::unordered_map<size_t, int> &_outputCellsNV, + std::unordered_map<size_t, _simplexNode_> &_nodesToBeInserted, #ifdef FINITE_TEMPERATURE - unordered_map<size_t, _thermal_point_> &_thermalPointsToBeInserted, - unordered_map<size_t, double> &_thermalPointEntropyToBeInserted, + std::unordered_map<size_t, _thermal_point_> &_thermalPointsToBeInserted, + std::unordered_map<size_t, double> &_thermalPointEntropyToBeInserted, #endif - unordered_map<size_t, int> &_materialIndexToBeInserted, const size_t &, - const int &, bool force = false, bool print = false); + std::unordered_map<size_t, int> &_materialIndexToBeInserted, + const size_t &, const int &, bool force = false, bool print = false); // ! interproc face removal template <typename faceRemoval> bool tryQCFaceRemovalDependent( const int &, const _face_ &, faceRemoval &, - vector<_pairKey_> &_outputKeys, - unordered_map<size_t, _simplexCell_> &_outputCells, - unordered_map<size_t, _matrix_> &_outputCellsBasis, - unordered_map<size_t, int> &_outputCellsNV, - unordered_map<size_t, _simplexNode_> &_nodesToBeInserted); + std::vector<_pairKey_> &_outputKeys, + std::unordered_map<size_t, _simplexCell_> &_outputCells, + std::unordered_map<size_t, _matrix_> &_outputCellsBasis, + std::unordered_map<size_t, int> &_outputCellsNV, + std::unordered_map<size_t, _simplexNode_> &_nodesToBeInserted); // ! interproc edge removal template <typename faceRemoval> bool tryQCEdgeRemovalDependent( const int &, const _face_ &, faceRemoval &, - vector<_pairKey_> &_outputKeys, - unordered_map<size_t, _simplexCell_> &_outputCells, - unordered_map<size_t, _matrix_> &_outputCellsBasis, - unordered_map<size_t, int> &_outputCellsNV, - unordered_map<size_t, _simplexNode_> &_nodesToBeInserted, + std::vector<_pairKey_> &_outputKeys, + std::unordered_map<size_t, _simplexCell_> &_outputCells, + std::unordered_map<size_t, _matrix_> &_outputCellsBasis, + std::unordered_map<size_t, int> &_outputCellsNV, + std::unordered_map<size_t, _simplexNode_> &_nodesToBeInserted, #ifdef FINITE_TEMPERATURE - unordered_map<size_t, _thermal_point_> &_thermalPointsToBeInserted, - unordered_map<size_t, double> &_thermalPointEntropyToBeInserted, + std::unordered_map<size_t, _thermal_point_> &_thermalPointsToBeInserted, + std::unordered_map<size_t, double> &_thermalPointEntropyToBeInserted, #endif - unordered_map<size_t, int> &_materialIndexToBeInserted, const size_t &, - const int &, bool print = false); + std::unordered_map<size_t, int> &_materialIndexToBeInserted, + const size_t &, const int &, bool print = false); - void gatherRequiredHaloMesh(const vector<size_t> &_elementIds); + void gatherRequiredHaloMesh(const std::vector<size_t> &_elementIds); // ! redistribute the local mesh void redistributeQCMesh(); @@ -1849,27 +1861,29 @@ public: void redistributeQCMesh_debug(); // ! remove unnecessary nodal data and build requried topologies - void packNodalDataAndTopology(const unordered_map<size_t, int> & + void + packNodalDataAndTopology(const std::unordered_map<size_t, int> & #ifdef FINITE_TEMPERATURE - , - const unordered_map<size_t, _thermal_point_> &, - const unordered_map<size_t, double> & + , + const std::unordered_map<size_t, _thermal_point_> &, + const std::unordered_map<size_t, double> & #endif - , - const bool &, const bool &, const bool &); + , + const bool &, const bool &, const bool &); // ! remove unnecessary nodal data and build requried topologies - void packNodalDataAndTopology(const unordered_map<size_t, double> &, - const unordered_map<size_t, int> &, - const unordered_map<size_t, int> &, - const vector<double> & + void + packNodalDataAndTopology(const std::unordered_map<size_t, double> &, + const std::unordered_map<size_t, int> &, + const std::unordered_map<size_t, int> &, + const std::vector<double> & #ifdef FINITE_TEMPERATURE - , - const unordered_map<size_t, _thermal_point_> &, - const unordered_map<size_t, double> & + , + const std::unordered_map<size_t, _thermal_point_> &, + const std::unordered_map<size_t, double> & #endif - , - const bool &, const bool &, const bool &); + , + const bool &, const bool &, const bool &); void reinitializeExchangeVectors() { reinitializeOverlapVectors(overlappingMeshData); diff --git a/src/mesh/qcMeshRepair.ipp b/src/mesh/qcMeshRepair.ipp index a4c565048..df31e12f0 100644 --- a/src/mesh/qcMeshRepair.ipp +++ b/src/mesh/qcMeshRepair.ipp @@ -1,4 +1,5 @@ #pragma once +#include "qcMesh.h" #include "vtkIO.h" #include <removeEdge.h> @@ -14,7 +15,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, trimBoundaryElements(); - array<_node_, K + 1> simplex; + std::array<_node_, K + 1> simplex; typename Base::independentRepairTask independentTask; typename Base::dependentRepairTask dependentTask; @@ -35,14 +36,14 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, decltype(typename Base::simplexQualityCompareTasks())> dependentBadElements; - vector<size_t> dependentBadElementIDs; - vector<double> dependentBadElementResidues; + std::vector<size_t> dependentBadElementIDs; + std::vector<double> dependentBadElementResidues; - vector<size_t> allProcDependentTaskKeys; - vector<double> allProcDependentTaskResidues; + std::vector<size_t> allProcDependentTaskKeys; + std::vector<double> allProcDependentTaskResidues; - vector<int> allProcsNoofDependentTasks(mpi_size); - vector<int> displacements(mpi_size, 0); + std::vector<int> allProcsNoofDependentTasks(mpi_size); + std::vector<int> displacements(mpi_size, 0); int totalDependentTasks, task_rank; @@ -91,12 +92,12 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, EdgeEraser_3 edgeEraser3D; FaceEraser_3 faceEraser3D; - unordered_map<size_t, _simplexCell_> newCells; - unordered_map<size_t, _matrix_> newCellsBasis; - unordered_map<size_t, int> newCellsNV; + std::unordered_map<size_t, _simplexCell_> newCells; + std::unordered_map<size_t, _matrix_> newCellsBasis; + std::unordered_map<size_t, int> newCellsNV; - vector<_pairKey_> cellsToDelete; - vector<_pairKey_> otherRanksCellsToDelete; + std::vector<_pairKey_> cellsToDelete; + std::vector<_pairKey_> otherRanksCellsToDelete; while (!independentBadElements.empty()) { @@ -210,9 +211,9 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // <<Base::meshNodes_.at(Base::meshCells_.at(si)[d].second).getPoint()<<endl; // } - // vector<_node_> ringNodes; - // vector<size_t> ringIds; - // vector<_pairKey_> incidentElements; + // std::vector<_node_> ringNodes; + // std::vector<size_t> ringIds; + // std::vector<_pairKey_> incidentElements; // edge.first = Base::meshCells_.at(si).getPairKey(); // edge.second = 0; // edge.third = 1; @@ -264,9 +265,9 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // bool onBoundary = Base::getIncidentCellsInOrder(edge, // std::back_inserter(incidentElements), ringNodes, ringIds); - // unordered_map<size_t, _ind_simplex_> outputTets; - // unordered_map<size_t, _node_> outputNodes; - // unordered_map<size_t, int> ranksOutputTets; + // std::unordered_map<size_t, _ind_simplex_> outputTets; + // std::unordered_map<size_t, _node_> outputNodes; + // std::unordered_map<size_t, int> ranksOutputTets; // Base::getSimplicesFromCells(incidentElements.begin(), // incidentElements.end(), outputTets, @@ -355,7 +356,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // assemble the dependent tasks in the order of decreasing quality residual for (int i = 0; i < totalDependentTasks; i++) { - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(displacements.cbegin(), displacements.cend(), i); task_rank = distance(displacements.cbegin(), it) - 1; @@ -369,12 +370,12 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, cout << mpi_rank << " found " << dependentBadElementResidues.size() << " dependent bad elements " << endl; - unordered_map<size_t, _simplexNode_> newNodes; + std::unordered_map<size_t, _simplexNode_> newNodes; #ifdef FINITE_TEMPERATURE - unordered_map<size_t, _thermal_point_> newThermalPoints; - unordered_map<size_t, double> newEntropies; + std::unordered_map<size_t, _thermal_point_> newThermalPoints; + std::unordered_map<size_t, double> newEntropies; #endif - unordered_map<size_t, int> newMaterialIndices; + std::unordered_map<size_t, int> newMaterialIndices; int ctr = 0; @@ -481,12 +482,12 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // upto here, node key maps are correct. // store remaining nodes keys and nodal data. - unordered_set<size_t> remainingNodes; + std::unordered_set<size_t> remainingNodes; - unordered_map<size_t, int> remainingNodesMaterialIDs; + std::unordered_map<size_t, int> remainingNodesMaterialIDs; #ifdef FINITE_TEMPERATURE - unordered_map<size_t, _thermal_point_> remainingNodesThermalDOFs; - unordered_map<size_t, double> remainingNodesEntropies; + std::unordered_map<size_t, _thermal_point_> remainingNodesThermalDOFs; + std::unordered_map<size_t, double> remainingNodesEntropies; #endif size_t nodeKey, nodeIndex; @@ -504,20 +505,20 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, remainingNodes.insert(nodeKey); remainingNodesMaterialIDs.insert( - make_pair(nodeKey, material_idx_of_nodes_[nodeIndex])); + std::make_pair(nodeKey, material_idx_of_nodes_[nodeIndex])); #ifdef FINITE_TEMPERATURE remainingNodesThermalDOFs.insert( - make_pair(nodeKey, repatoms.thermal_coordinates_[nodeIndex])); + std::make_pair(nodeKey, repatoms.thermal_coordinates_[nodeIndex])); remainingNodesEntropies.insert( - make_pair(nodeKey, repatoms.entropy_[nodeIndex])); + std::make_pair(nodeKey, repatoms.entropy_[nodeIndex])); #endif } } } // ! remove the unnecessary nodes. store the data of remaining nodes - unordered_set<size_t> keysToRemove; + std::unordered_set<size_t> keysToRemove; for (const auto &n : Base::meshNodes_) { if (remainingNodes.find(n.first) == remainingNodes.end() && keysToRemove.find(n.first) == keysToRemove.end()) { @@ -641,7 +642,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // // assemble the dependent tasks in the order of decreasing quality residual // for(int i=0; i<totalDependentTasks; i++) // { - // const vector<int>::const_iterator it = + // const std::vector<int>::const_iterator it = // upper_bound(displacements.cbegin(), // displacements.cend(), i); // task_rank = distance(displacements.cbegin(), it) - 1; @@ -854,7 +855,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // // assemble the dependent tasks in the order of decreasing quality residual // for(int i=0; i<totalDependentTasks; i++) // { - // const vector<int>::const_iterator it = + // const std::vector<int>::const_iterator it = // upper_bound(displacements.cbegin(), // displacements.cend(), i); // task_rank = distance(displacements.cbegin(), it) - 1; @@ -996,4 +997,4 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // ctr++; // } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/redistributeMesh.ipp b/src/mesh/redistributeMesh.ipp index 1dc89c90b..edbafb1a9 100644 --- a/src/mesh/redistributeMesh.ipp +++ b/src/mesh/redistributeMesh.ipp @@ -8,6 +8,7 @@ © 2020 ETH Zurich, Mechanics and Materials Lab */ #pragma once +#include "qcMesh.h" namespace meshing { /** @@ -34,7 +35,7 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // and build only halo to local connectivity Base::buildAdjacencyHalo(false, true); - vector<unsigned int> noofCellKeysAllRanks(mpi_size); + std::vector<unsigned int> noofCellKeysAllRanks(mpi_size); size_t totalNoofCells = accumulate(noofCellKeysAllRanks.begin(), noofCellKeysAllRanks.end(), 0); @@ -43,8 +44,8 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, noofCellKeysAllRanks); // build CSR adjacencies and parmetis data structures - vector<int> cellAdjncy; - vector<int> ixadj; + std::vector<int> cellAdjncy; + std::vector<int> ixadj; cellAdjncy.reserve(Base::meshCells_.size() * (K + 1)); ixadj.resize(Base::meshCells_.size() + 1, 0); @@ -62,23 +63,23 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } cellAdjncy.shrink_to_fit(); - vector<int> cellDist(mpi_size + 1, 0); - vector<int> vwgt(totalNoofCells, 1); - vector<int> el_part; + std::vector<int> cellDist(mpi_size + 1, 0); + std::vector<int> vwgt(totalNoofCells, 1); + std::vector<int> el_part; int n_constraint = 1; int n_parts = mpi_size; int options[3]; int wgtflag, numflag; - vector<float> tpwgts; - vector<float> ubvec; + std::vector<float> tpwgts; + std::vector<float> ubvec; for (int rank = 0; rank < mpi_size; rank++) { cellDist[rank + 1] = cellDist[rank] + noofCellKeysAllRanks[rank]; } - vector<int> adjwgt(cellAdjncy.size(), 1); + std::vector<int> adjwgt(cellAdjncy.size(), 1); wgtflag = 0; numflag = 0; @@ -102,54 +103,54 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, &tpwgts[0], &ubvec[0], options, &edgecut, &el_part[0], &mpi_comm); - vector<vector<_ind_simplex_>> elementsPartition(mpi_size); - vector<vector<_stl_matrix_>> elementsBasisPartition(mpi_size); - vector<vector<double>> elementsJacobianPartition(mpi_size); - vector<vector<double>> elementsDensityPartition(mpi_size); + std::vector<std::vector<_ind_simplex_>> elementsPartition(mpi_size); + std::vector<std::vector<_stl_matrix_>> elementsBasisPartition(mpi_size); + std::vector<std::vector<double>> elementsJacobianPartition(mpi_size); + std::vector<std::vector<double>> elementsDensityPartition(mpi_size); - vector<vector<double>> elementsCentralWeightsPartition(mpi_size); + std::vector<std::vector<double>> elementsCentralWeightsPartition(mpi_size); - vector<vector<int>> elementsAtomisticFlagsPartition(mpi_size); + std::vector<std::vector<int>> elementsAtomisticFlagsPartition(mpi_size); - vector<vector<_node_>> nodesPartition(mpi_size); - vector<vector<size_t>> nodesIDsPartition(mpi_size); - vector<vector<int>> materialIDsPartition(mpi_size); + std::vector<std::vector<_node_>> nodesPartition(mpi_size); + std::vector<std::vector<size_t>> nodesIDsPartition(mpi_size); + std::vector<std::vector<int>> materialIDsPartition(mpi_size); - vector<vector<double>> nodesWeightsPartition(mpi_size); - vector<vector<int>> nodesFlagsPartition(mpi_size); + std::vector<std::vector<double>> nodesWeightsPartition(mpi_size); + std::vector<std::vector<int>> nodesFlagsPartition(mpi_size); #ifdef FINITE_TEMPERATURE - vector<vector<_thermal_point_>> nodesThermalDOFsPartition(mpi_size); - vector<vector<double>> nodesEntropiesPartition(mpi_size); + std::vector<std::vector<_thermal_point_>> nodesThermalDOFsPartition(mpi_size); + std::vector<std::vector<double>> nodesEntropiesPartition(mpi_size); #endif - unordered_map<size_t, _simplexNode_> remainingNodes; - unordered_map<size_t, int> remainingNodesMaterialIDs; + std::unordered_map<size_t, _simplexNode_> remainingNodes; + std::unordered_map<size_t, int> remainingNodesMaterialIDs; - unordered_map<size_t, double> remainingNodesWeights; - unordered_map<size_t, int> remainingNodesFlags; + std::unordered_map<size_t, double> remainingNodesWeights; + std::unordered_map<size_t, int> remainingNodesFlags; #ifdef FINITE_TEMPERATURE - unordered_map<size_t, _thermal_point_> remainingNodesThermalDOFs; - unordered_map<size_t, double> remainingNodesEntropies; + std::unordered_map<size_t, _thermal_point_> remainingNodesThermalDOFs; + std::unordered_map<size_t, double> remainingNodesEntropies; #endif - vector<vector<bool>> addedNodes(mpi_size); + std::vector<std::vector<bool>> addedNodes(mpi_size); for (int rank = 0; rank < mpi_size; rank++) { addedNodes[rank].resize(Base::meshNodes_.size(), false); } - vector<size_t> noofElementsSend(mpi_size, 0); - vector<size_t> noofNodesSend(mpi_size, 0); + std::vector<size_t> noofElementsSend(mpi_size, 0); + std::vector<size_t> noofNodesSend(mpi_size, 0); int elementRank; _ind_simplex_ elementSend; size_t nodeKey, nodeIndex; - vector<size_t> indicesToDelete; + std::vector<size_t> indicesToDelete; _stl_matrix_ stl_basis; - vector<double> localElementCentralWeights; + std::vector<double> localElementCentralWeights; localElementCentralWeights.reserve(Base::meshCells_.size()); for (size_t i_el = 0; i_el < Base::meshCells_.size(); i_el++) { @@ -166,22 +167,22 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, if (elementRank == mpi_rank) { if (remainingNodes.find(nodeKey) == remainingNodes.end()) { remainingNodes.insert( - make_pair(nodeKey, Base::meshNodes_.at(nodeKey))); + std::make_pair(nodeKey, Base::meshNodes_.at(nodeKey))); remainingNodes.at(nodeKey).setPeriodicBoundaryFlag(false); remainingNodesMaterialIDs.insert( - make_pair(nodeKey, material_idx_of_nodes_[nodeIndex])); + std::make_pair(nodeKey, material_idx_of_nodes_[nodeIndex])); remainingNodesWeights.insert( - make_pair(nodeKey, samplingAtoms.nodalWeights_[nodeIndex])); + std::make_pair(nodeKey, samplingAtoms.nodalWeights_[nodeIndex])); remainingNodesFlags.insert( - make_pair(nodeKey, repatoms.ifFixed_[nodeIndex])); + std::make_pair(nodeKey, repatoms.ifFixed_[nodeIndex])); #ifdef FINITE_TEMPERATURE - remainingNodesThermalDOFs.insert( - make_pair(nodeKey, repatoms.thermal_coordinates_[nodeIndex])); + remainingNodesThermalDOFs.insert(std::make_pair( + nodeKey, repatoms.thermal_coordinates_[nodeIndex])); remainingNodesEntropies.insert( - make_pair(nodeKey, repatoms.entropy_[nodeIndex])); + std::make_pair(nodeKey, repatoms.entropy_[nodeIndex])); #endif } } else { @@ -273,8 +274,8 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } // exchange the noof elements and nodes - vector<size_t> noofElementsRecv(mpi_size); - vector<size_t> noofNodesRecv(mpi_size); + std::vector<size_t> noofElementsRecv(mpi_size); + std::vector<size_t> noofNodesRecv(mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<size_t>( noofElementsSend, noofElementsRecv, mpi_size); @@ -282,23 +283,23 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, mpi_utilities::MPIExchangeBuffers_NonBlocking<size_t>( noofNodesSend, noofNodesRecv, mpi_size); - vector<vector<_ind_simplex_>> elementsRecv(mpi_size); - vector<vector<_stl_matrix_>> elementsBasisRecv(mpi_size); - vector<vector<double>> elementsJacobianRecv(mpi_size); - vector<vector<double>> elementsDensityRecv(mpi_size); - vector<vector<double>> elementsCentralWeightsRecv(mpi_size); - vector<vector<int>> elementsAtomisticFlagsRecv(mpi_size); + std::vector<std::vector<_ind_simplex_>> elementsRecv(mpi_size); + std::vector<std::vector<_stl_matrix_>> elementsBasisRecv(mpi_size); + std::vector<std::vector<double>> elementsJacobianRecv(mpi_size); + std::vector<std::vector<double>> elementsDensityRecv(mpi_size); + std::vector<std::vector<double>> elementsCentralWeightsRecv(mpi_size); + std::vector<std::vector<int>> elementsAtomisticFlagsRecv(mpi_size); - vector<vector<_node_>> nodesRecv(mpi_size); - vector<vector<size_t>> nodeIDsRecv(mpi_size); - vector<vector<int>> materialIDsRecv(mpi_size); + std::vector<std::vector<_node_>> nodesRecv(mpi_size); + std::vector<std::vector<size_t>> nodeIDsRecv(mpi_size); + std::vector<std::vector<int>> materialIDsRecv(mpi_size); - vector<vector<double>> nodesWeightsRecv(mpi_size); - vector<vector<int>> nodesFlagsRecv(mpi_size); + std::vector<std::vector<double>> nodesWeightsRecv(mpi_size); + std::vector<std::vector<int>> nodesFlagsRecv(mpi_size); #ifdef FINITE_TEMPERATURE - vector<vector<_thermal_point_>> nodesThermalDOFsRecv(mpi_size); - vector<vector<double>> nodesEntropiesRecv(mpi_size); + std::vector<std::vector<_thermal_point_>> nodesThermalDOFsRecv(mpi_size); + std::vector<std::vector<double>> nodesEntropiesRecv(mpi_size); #endif for (int rank = 0; rank < mpi_size; rank++) { @@ -373,11 +374,12 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, for (size_t i_el = 0; i_el < elementsRecv[rank].size(); i_el++) { cell.resetNeighbours(); for (int d = 0; d < K + 1; d++) { - cell.setNode(make_pair(mpi_rank, elementsRecv[rank][i_el][d]), d); + cell.setNode(std::make_pair(mpi_rank, elementsRecv[rank][i_el][d]), + d); } - cell.setPairKey(make_pair(mpi_rank, Base::newCellKey_)); + cell.setPairKey(std::make_pair(mpi_rank, Base::newCellKey_)); cell.setMeshIndex(Base::simplex_index_to_key_.size()); - Base::meshCells_.insert(make_pair(Base::newCellKey_, cell)); + Base::meshCells_.insert(std::make_pair(Base::newCellKey_, cell)); Base::simplex_index_to_key_.push_back(Base::newCellKey_); m = Eigen::Map<_matrix_>(elementsBasisRecv[rank][i_el].data(), K, K); @@ -404,21 +406,21 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, node.setNode(nodesRecv[rank][i_nd], nodeIDsRecv[rank][i_nd]); node.setPeriodicBoundaryFlag(false); node.setProcBoundaryFlag(false); - remainingNodes.insert(make_pair(nodeIDsRecv[rank][i_nd], node)); + remainingNodes.insert(std::make_pair(nodeIDsRecv[rank][i_nd], node)); - remainingNodesMaterialIDs.insert( - make_pair(nodeIDsRecv[rank][i_nd], materialIDsRecv[rank][i_nd])); + remainingNodesMaterialIDs.insert(std::make_pair( + nodeIDsRecv[rank][i_nd], materialIDsRecv[rank][i_nd])); - remainingNodesWeights.insert( - make_pair(nodeIDsRecv[rank][i_nd], nodesWeightsRecv[rank][i_nd])); + remainingNodesWeights.insert(std::make_pair( + nodeIDsRecv[rank][i_nd], nodesWeightsRecv[rank][i_nd])); - remainingNodesFlags.insert( - make_pair(nodeIDsRecv[rank][i_nd], nodesFlagsRecv[rank][i_nd])); + remainingNodesFlags.insert(std::make_pair( + nodeIDsRecv[rank][i_nd], nodesFlagsRecv[rank][i_nd])); #ifdef FINITE_TEMPERATURE - remainingNodesThermalDOFs.insert(make_pair( + remainingNodesThermalDOFs.insert(std::make_pair( nodeIDsRecv[rank][i_nd], nodesThermalDOFsRecv[rank][i_nd])); - remainingNodesEntropies.insert(make_pair( + remainingNodesEntropies.insert(std::make_pair( nodeIDsRecv[rank][i_nd], nodesEntropiesRecv[rank][i_nd])); #endif } @@ -427,16 +429,16 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } for (int rank = 0; rank < mpi_size; rank++) { - vector<_ind_simplex_>().swap(elementsPartition[rank]); - vector<_node_>().swap(nodesPartition[rank]); - vector<_stl_matrix_>().swap(elementsBasisPartition[rank]); - vector<double>().swap(elementsJacobianPartition[rank]); - vector<double>().swap(elementsDensityPartition[rank]); + std::vector<_ind_simplex_>().swap(elementsPartition[rank]); + std::vector<_node_>().swap(nodesPartition[rank]); + std::vector<_stl_matrix_>().swap(elementsBasisPartition[rank]); + std::vector<double>().swap(elementsJacobianPartition[rank]); + std::vector<double>().swap(elementsDensityPartition[rank]); - vector<double>().swap(elementsCentralWeightsPartition[rank]); + std::vector<double>().swap(elementsCentralWeightsPartition[rank]); - vector<size_t>().swap(nodesIDsPartition[rank]); - vector<int>().swap(materialIDsPartition[rank]); + std::vector<size_t>().swap(nodesIDsPartition[rank]); + std::vector<int>().swap(materialIDsPartition[rank]); } // renumber cells. Changes the keys. But order remains same @@ -468,4 +470,4 @@ inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/redistributeMesh_debug.ipp b/src/mesh/redistributeMesh_debug.ipp index d2c4d0946..a3669369c 100644 --- a/src/mesh/redistributeMesh_debug.ipp +++ b/src/mesh/redistributeMesh_debug.ipp @@ -7,6 +7,7 @@ \author P. Gupta */ #pragma once +#include "qcMesh.h" namespace meshing { /** @@ -36,7 +37,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, // and build only halo to local connectivity Base::buildAdjacencyHalo(false, true); - vector<unsigned int> noofCellKeysAllRanks(mpi_size); + std::vector<unsigned int> noofCellKeysAllRanks(mpi_size); size_t totalNoofCells = accumulate(noofCellKeysAllRanks.begin(), noofCellKeysAllRanks.end(), 0); @@ -45,8 +46,8 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, noofCellKeysAllRanks); // build CSR adjacencies and parmetis data structures - vector<int> cellAdjncy; - vector<int> ixadj; + std::vector<int> cellAdjncy; + std::vector<int> ixadj; cellAdjncy.reserve(Base::meshCells_.size() * (K + 1)); ixadj.resize(Base::meshCells_.size() + 1, 0); @@ -64,23 +65,23 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } cellAdjncy.shrink_to_fit(); - vector<int> cellDist(mpi_size + 1, 0); - vector<int> vwgt(totalNoofCells, 1); - vector<int> el_part; + std::vector<int> cellDist(mpi_size + 1, 0); + std::vector<int> vwgt(totalNoofCells, 1); + std::vector<int> el_part; int n_constraint = 1; int n_parts = mpi_size; int options[3]; int wgtflag, numflag; - vector<float> tpwgts; - vector<float> ubvec; + std::vector<float> tpwgts; + std::vector<float> ubvec; for (int rank = 0; rank < mpi_size; rank++) { cellDist[rank + 1] = cellDist[rank] + noofCellKeysAllRanks[rank]; } - vector<int> adjwgt(cellAdjncy.size(), 1); + std::vector<int> adjwgt(cellAdjncy.size(), 1); wgtflag = 0; numflag = 0; @@ -104,40 +105,40 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, &tpwgts[0], &ubvec[0], options, &edgecut, &el_part[0], &mpi_comm); - vector<vector<_ind_simplex_>> elementsPartition(mpi_size); - vector<vector<_stl_matrix_>> elementsBasisPartition(mpi_size); - vector<vector<double>> elementsJacobianPartition(mpi_size); - vector<vector<double>> elementsDensityPartition(mpi_size); + std::vector<std::vector<_ind_simplex_>> elementsPartition(mpi_size); + std::vector<std::vector<_stl_matrix_>> elementsBasisPartition(mpi_size); + std::vector<std::vector<double>> elementsJacobianPartition(mpi_size); + std::vector<std::vector<double>> elementsDensityPartition(mpi_size); - vector<vector<_node_>> nodesPartition(mpi_size); - vector<vector<size_t>> nodesIDsPartition(mpi_size); - vector<vector<int>> materialIDsPartition(mpi_size); + std::vector<std::vector<_node_>> nodesPartition(mpi_size); + std::vector<std::vector<size_t>> nodesIDsPartition(mpi_size); + std::vector<std::vector<int>> materialIDsPartition(mpi_size); #ifdef FINITE_TEMPERATURE - vector<vector<_thermal_point_>> nodesThermalDOFsPartition(mpi_size); - vector<vector<double>> nodesEntropiesPartition(mpi_size); + std::vector<std::vector<_thermal_point_>> nodesThermalDOFsPartition(mpi_size); + std::vector<std::vector<double>> nodesEntropiesPartition(mpi_size); #endif - unordered_map<size_t, _simplexNode_> remainingNodes; - unordered_map<size_t, int> remainingNodesMaterialIDs; + std::unordered_map<size_t, _simplexNode_> remainingNodes; + std::unordered_map<size_t, int> remainingNodesMaterialIDs; #ifdef FINITE_TEMPERATURE - unordered_map<size_t, _thermal_point_> remainingNodesThermalDOFs; - unordered_map<size_t, double> remainingNodesEntropies; + std::unordered_map<size_t, _thermal_point_> remainingNodesThermalDOFs; + std::unordered_map<size_t, double> remainingNodesEntropies; #endif - vector<vector<bool>> addedNodes(mpi_size); + std::vector<std::vector<bool>> addedNodes(mpi_size); for (int rank = 0; rank < mpi_size; rank++) { addedNodes[rank].resize(Base::meshNodes_.size(), false); } - vector<size_t> noofElementsSend(mpi_size, 0); - vector<size_t> noofNodesSend(mpi_size, 0); + std::vector<size_t> noofElementsSend(mpi_size, 0); + std::vector<size_t> noofNodesSend(mpi_size, 0); int elementRank; _ind_simplex_ elementSend; size_t nodeKey, nodeIndex; - vector<size_t> indicesToDelete; + std::vector<size_t> indicesToDelete; _stl_matrix_ stl_basis; for (size_t i_el = 0; i_el < Base::meshCells_.size(); i_el++) { @@ -154,17 +155,17 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, if (elementRank == mpi_rank) { if (remainingNodes.find(nodeKey) == remainingNodes.end()) { remainingNodes.insert( - make_pair(nodeKey, Base::meshNodes_.at(nodeKey))); + std::make_pair(nodeKey, Base::meshNodes_.at(nodeKey))); remainingNodes.at(nodeKey).setPeriodicBoundaryFlag(false); remainingNodesMaterialIDs.insert( - make_pair(nodeKey, material_idx_of_nodes_[nodeIndex])); + std::make_pair(nodeKey, material_idx_of_nodes_[nodeIndex])); #ifdef FINITE_TEMPERATURE - remainingNodesThermalDOFs.insert( - make_pair(nodeKey, repatoms.thermal_coordinates_[nodeIndex])); + remainingNodesThermalDOFs.insert(std::make_pair( + nodeKey, repatoms.thermal_coordinates_[nodeIndex])); remainingNodesEntropies.insert( - make_pair(nodeKey, repatoms.entropy_[nodeIndex])); + std::make_pair(nodeKey, repatoms.entropy_[nodeIndex])); #endif } } else { @@ -228,8 +229,8 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } // exchange the noof elements and nodes - vector<size_t> noofElementsRecv(mpi_size); - vector<size_t> noofNodesRecv(mpi_size); + std::vector<size_t> noofElementsRecv(mpi_size); + std::vector<size_t> noofNodesRecv(mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<size_t>( noofElementsSend, noofElementsRecv, mpi_size); @@ -237,18 +238,18 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, mpi_utilities::MPIExchangeBuffers_NonBlocking<size_t>( noofNodesSend, noofNodesRecv, mpi_size); - vector<vector<_ind_simplex_>> elementsRecv(mpi_size); - vector<vector<_stl_matrix_>> elementsBasisRecv(mpi_size); - vector<vector<double>> elementsJacobianRecv(mpi_size); - vector<vector<double>> elementsDensityRecv(mpi_size); + std::vector<std::vector<_ind_simplex_>> elementsRecv(mpi_size); + std::vector<std::vector<_stl_matrix_>> elementsBasisRecv(mpi_size); + std::vector<std::vector<double>> elementsJacobianRecv(mpi_size); + std::vector<std::vector<double>> elementsDensityRecv(mpi_size); - vector<vector<_node_>> nodesRecv(mpi_size); - vector<vector<size_t>> nodeIDsRecv(mpi_size); - vector<vector<int>> materialIDsRecv(mpi_size); + std::vector<std::vector<_node_>> nodesRecv(mpi_size); + std::vector<std::vector<size_t>> nodeIDsRecv(mpi_size); + std::vector<std::vector<int>> materialIDsRecv(mpi_size); #ifdef FINITE_TEMPERATURE - vector<vector<_thermal_point_>> nodesThermalDOFsRecv(mpi_size); - vector<vector<double>> nodesEntropiesRecv(mpi_size); + std::vector<std::vector<_thermal_point_>> nodesThermalDOFsRecv(mpi_size); + std::vector<std::vector<double>> nodesEntropiesRecv(mpi_size); #endif for (int rank = 0; rank < mpi_size; rank++) { @@ -304,11 +305,12 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, cell.resetNeighbours(); for (int d = 0; d < K + 1; d++) { - cell.setNode(make_pair(mpi_rank, elementsRecv[rank][i_el][d]), d); + cell.setNode(std::make_pair(mpi_rank, elementsRecv[rank][i_el][d]), + d); } - cell.setPairKey(make_pair(mpi_rank, Base::newCellKey_)); + cell.setPairKey(std::make_pair(mpi_rank, Base::newCellKey_)); cell.setMeshIndex(Base::simplex_index_to_key_.size()); - Base::meshCells_.insert(make_pair(Base::newCellKey_, cell)); + Base::meshCells_.insert(std::make_pair(Base::newCellKey_, cell)); Base::simplex_index_to_key_.push_back(Base::newCellKey_); m = Eigen::Map<_matrix_>(elementsBasisRecv[rank][i_el].data(), K, K); @@ -327,18 +329,18 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, if (remainingNodes.find(nodeIDsRecv[rank][i_nd]) == remainingNodes.end()) { node.setNode(nodesRecv[rank][i_nd], nodeIDsRecv[rank][i_nd]); - remainingNodes.insert(make_pair(nodeIDsRecv[rank][i_nd], node)); + remainingNodes.insert(std::make_pair(nodeIDsRecv[rank][i_nd], node)); remainingNodes.at(nodeIDsRecv[rank][i_nd]) .setPeriodicBoundaryFlag(false); - remainingNodesMaterialIDs.insert( - make_pair(nodeIDsRecv[rank][i_nd], materialIDsRecv[rank][i_nd])); + remainingNodesMaterialIDs.insert(std::make_pair( + nodeIDsRecv[rank][i_nd], materialIDsRecv[rank][i_nd])); #ifdef FINITE_TEMPERATURE - remainingNodesThermalDOFs.insert(make_pair( + remainingNodesThermalDOFs.insert(std::make_pair( nodeIDsRecv[rank][i_nd], nodesThermalDOFsRecv[rank][i_nd])); - remainingNodesEntropies.insert(make_pair( + remainingNodesEntropies.insert(std::make_pair( nodeIDsRecv[rank][i_nd], nodesEntropiesRecv[rank][i_nd])); #endif } @@ -347,14 +349,14 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } for (int rank = 0; rank < mpi_size; rank++) { - vector<_ind_simplex_>().swap(elementsPartition[rank]); - vector<_node_>().swap(nodesPartition[rank]); - vector<_stl_matrix_>().swap(elementsBasisPartition[rank]); - vector<double>().swap(elementsJacobianPartition[rank]); - vector<double>().swap(elementsDensityPartition[rank]); - - vector<size_t>().swap(nodesIDsPartition[rank]); - vector<int>().swap(materialIDsPartition[rank]); + std::vector<_ind_simplex_>().swap(elementsPartition[rank]); + std::vector<_node_>().swap(nodesPartition[rank]); + std::vector<_stl_matrix_>().swap(elementsBasisPartition[rank]); + std::vector<double>().swap(elementsJacobianPartition[rank]); + std::vector<double>().swap(elementsDensityPartition[rank]); + + std::vector<size_t>().swap(nodesIDsPartition[rank]); + std::vector<int>().swap(materialIDsPartition[rank]); } // add the remaining nodes and cells @@ -417,4 +419,4 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, } } } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/removeEdge.h b/src/mesh/removeEdge.h index b9fa1c5ed..96bbc71c2 100644 --- a/src/mesh/removeEdge.h +++ b/src/mesh/removeEdge.h @@ -14,17 +14,14 @@ #include <assert.h> -using namespace std; -using namespace geometry; - namespace meshing { // specific to 3D class EdgeEraser_3 { public: typedef point<3> Point; - typedef array<int, 3> Triangle; - typedef array<Point, 3 + 1> Tetrahedron; - typedef array<size_t, 3 + 1> _ind_simplex_; + typedef std::array<int, 3> Triangle; + typedef std::array<Point, 3 + 1> Tetrahedron; + typedef std::array<size_t, 3 + 1> _ind_simplex_; private: // size of vertex ring around the edge @@ -33,17 +30,17 @@ private: Point source_, target_; // ring of points around the edge - vector<Point> ring_; + std::vector<Point> ring_; // quality of different ring triangulations. // Klincsek’s dynamic programming for triangulation - vector<double> quality_; + std::vector<double> quality_; // index_[i,j] gives triangle i, j, index_[i,j] - vector<int> index_; + std::vector<int> index_; // triangle indices of ring triangulation - vector<Triangle> triangles_; + std::vector<Triangle> triangles_; public: EdgeEraser_3() @@ -88,9 +85,9 @@ public: void buildTrianglesRecursive(const int i, const int j); - void getReconnectedTetra(unordered_map<size_t, _ind_simplex_> &, - unordered_map<size_t, Point> &, - unordered_map<size_t, int> &); + void getReconnectedTetra(std::unordered_map<size_t, _ind_simplex_> &, + std::unordered_map<size_t, Point> &, + std::unordered_map<size_t, int> &); // Return the worse quality of the tetrahedra: // ring_[i], ring_[k], ring_[j], target_ @@ -124,4 +121,4 @@ public: }; } // namespace meshing -#include <removeEdge.ipp> \ No newline at end of file +#include <removeEdge.ipp> diff --git a/src/mesh/removeEdge.ipp b/src/mesh/removeEdge.ipp index 6f2dec3f0..58fad6791 100644 --- a/src/mesh/removeEdge.ipp +++ b/src/mesh/removeEdge.ipp @@ -1,4 +1,3 @@ - #pragma once #include "removeEdge.h" @@ -47,10 +46,10 @@ inline void EdgeEraser_3::fillKlincsekTable() { for (int k = i + 1; k <= j - 1; ++k) { q = computeQualityResidual(i, j, k); if (j > k + 1) { - q = min(q, quality(k, j)); + q = std::min(q, quality(k, j)); } if (k > i + 1) { - q = min(q, quality(i, k)); + q = std::min(q, quality(i, k)); } if (k == i + 1 || q >= quality(i, j)) { quality_[N_ * i + j] = q; @@ -160,21 +159,21 @@ inline double EdgeEraser_3::computeQualityResidual(const int i, const int k, assert(!std::isnan(r2)); - return min(r1, r2); + return std::min(r1, r2); } -inline void -EdgeEraser_3::getReconnectedTetra(unordered_map<size_t, _ind_simplex_> &_cells, - unordered_map<size_t, Point> &_nodes, - unordered_map<size_t, int> &_ranks) { +inline void EdgeEraser_3::getReconnectedTetra( + std::unordered_map<size_t, _ind_simplex_> &_cells, + std::unordered_map<size_t, Point> &_nodes, + std::unordered_map<size_t, int> &_ranks) { double reconnected_volume = 0.0; size_t nodeCtr = 0; size_t cellCtr = 0; - _nodes.insert(make_pair(nodeCtr, source_)); + _nodes.insert(std::make_pair(nodeCtr, source_)); nodeCtr++; - _nodes.insert(make_pair(nodeCtr, target_)); + _nodes.insert(std::make_pair(nodeCtr, target_)); nodeCtr++; _ind_simplex_ tet1; @@ -185,19 +184,19 @@ EdgeEraser_3::getReconnectedTetra(unordered_map<size_t, _ind_simplex_> &_cells, tet1[d] = nodeCtr; tet2[d + 1] = nodeCtr; if (_nodes.find(nodeCtr) == _nodes.end()) { - _nodes.insert(make_pair(nodeCtr, ring_[triangles_[i][d]])); + _nodes.insert(std::make_pair(nodeCtr, ring_[triangles_[i][d]])); nodeCtr++; } } tet2[0] = 0; tet1[3] = 1; - _cells.insert(make_pair(cellCtr, tet1)); - _ranks.insert(make_pair(cellCtr, mpi_rank)); + _cells.insert(std::make_pair(cellCtr, tet1)); + _ranks.insert(std::make_pair(cellCtr, mpi_rank)); cellCtr++; - _cells.insert(make_pair(cellCtr, tet2)); - _ranks.insert(make_pair(cellCtr, mpi_rank)); + _cells.insert(std::make_pair(cellCtr, tet2)); + _ranks.insert(std::make_pair(cellCtr, mpi_rank)); cellCtr++; } } diff --git a/src/mesh/removeFace.h b/src/mesh/removeFace.h index 19963bc28..f6d3e891a 100644 --- a/src/mesh/removeFace.h +++ b/src/mesh/removeFace.h @@ -13,26 +13,23 @@ #include <assert.h> -using namespace std; -using namespace geometry; - namespace meshing { // specific to 3D class FaceEraser_3 { public: typedef point<3> Point; - typedef array<int, 3> Triangle; - typedef array<Point, 3 + 1> Tetrahedron; - typedef array<size_t, 3 + 1> _ind_simplex_; + typedef std::array<int, 3> Triangle; + typedef std::array<Point, 3 + 1> Tetrahedron; + typedef std::array<size_t, 3 + 1> _ind_simplex_; public: // The source and target of the edge. Point source_, target_; // The three vertices in the face shared by the two initial tetrahedra. - array<Point, 3> face_; + std::array<Point, 3> face_; // triangular faces - vector<Triangle> candidateFaces_; - vector<Point> candidateVertices_; + std::vector<Triangle> candidateFaces_; + std::vector<Point> candidateVertices_; public: FaceEraser_3() : source_(), target_() {} @@ -60,4 +57,4 @@ public: }; } // namespace meshing -#include <removeFace.ipp> \ No newline at end of file +#include <removeFace.ipp> diff --git a/src/mesh/removeFace.ipp b/src/mesh/removeFace.ipp index 1ea4a7129..088fb304f 100644 --- a/src/mesh/removeFace.ipp +++ b/src/mesh/removeFace.ipp @@ -28,7 +28,7 @@ inline double FaceEraser_3::computeQuality2() const { tet = {{source_, face_[0], face_[1], face_[2]}}; r2 = -simplexMetricResidual<3>(tet); - return min(r1, r2); + return std::min(r1, r2); } inline double FaceEraser_3::computeQuality3() const { @@ -45,7 +45,7 @@ inline double FaceEraser_3::computeQuality3() const { tet = {{source_, target_, face_[2], face_[0]}}; r3 = -simplexMetricResidual<3>(tet); - return min(r1, min(r2, r3)); + return std::min(r1, std::min(r2, r3)); } inline bool @@ -66,4 +66,4 @@ FaceEraser_3::checkVolumeConsistency(const double &_old_volume) const { return (abs(reconnected_volume - _old_volume) < 1.0e-4); } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/mesh/renumberMesh.ipp b/src/mesh/renumberMesh.ipp index b427ee1f8..373cb2f61 100644 --- a/src/mesh/renumberMesh.ipp +++ b/src/mesh/renumberMesh.ipp @@ -7,6 +7,7 @@ \author P. Gupta */ #pragma once +#include "qcMesh.h" namespace meshing { template <int D, int K> void KSimplexDMesh<D, K>::renumberCells() { @@ -15,7 +16,7 @@ template <int D, int K> void KSimplexDMesh<D, K>::renumberCells() { // and their neighbours. The local ordering doesn't change. // so any element data doesn't need to be reordered - vector<unsigned int> noofCellKeysAllRanks(mpi_size); + std::vector<unsigned int> noofCellKeysAllRanks(mpi_size); mpi_utilities::ALLGATHER<unsigned int>(meshCells_.size(), noofCellKeysAllRanks); @@ -32,28 +33,28 @@ template <int D, int K> void KSimplexDMesh<D, K>::renumberCells() { } // new key of ith index is cellKeyOffset+i - unordered_map<size_t, size_t> oldKeyToNewKey; + std::unordered_map<size_t, size_t> oldKeyToNewKey; oldKeyToNewKey.reserve(meshCells_.size()); size_t oldKey, newKey; - unordered_map<size_t, _simplexCell_> newMeshCells; + std::unordered_map<size_t, _simplexCell_> newMeshCells; newMeshCells.reserve(meshCells_.size()); for (size_t i = 0; i < simplex_index_to_key_.size(); i++) { oldKey = simplex_index_to_key_[i]; newKey = cellKeyOffset + i; - oldKeyToNewKey.insert(make_pair(oldKey, newKey)); + oldKeyToNewKey.insert(std::make_pair(oldKey, newKey)); simplex_index_to_key_[i] = newKey; - newMeshCells.insert(make_pair(newKey, meshCells_.at(oldKey))); + newMeshCells.insert(std::make_pair(newKey, meshCells_.at(oldKey))); newMeshCells.at(newKey).setMeshIndex(i); - newMeshCells.at(newKey).setPairKey(make_pair(mpi_rank, newKey)); + newMeshCells.at(newKey).setPairKey(std::make_pair(mpi_rank, newKey)); } meshCells_.swap(newMeshCells); - unordered_map<size_t, _simplexCell_>().swap(newMeshCells); + std::unordered_map<size_t, _simplexCell_>().swap(newMeshCells); _pairKey_ oldNeighbourKey, newNeighbourKey; @@ -66,8 +67,8 @@ template <int D, int K> void KSimplexDMesh<D, K>::renumberCells() { assert(oldKeyToNewKey.find(oldNeighbourKey.second) != oldKeyToNewKey.end()); - newNeighbourKey = make_pair(oldNeighbourKey.first, - oldKeyToNewKey.at(oldNeighbourKey.second)); + newNeighbourKey = std::make_pair( + oldNeighbourKey.first, oldKeyToNewKey.at(oldNeighbourKey.second)); keyCellPair.second.setNeighbour(newNeighbourKey, d); } @@ -86,7 +87,7 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { // this simplifies my life. Don't know if its going to be used // by anyone else though - vector<bool> if_ghosts(meshNodes_.size(), false); + std::vector<bool> if_ghosts(meshNodes_.size(), false); int node_proc; size_t node_index; @@ -120,9 +121,9 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { assert(noof_ghosts_ <= meshNodes_.size()); // index of local nodes in local vector of keys (node_index_to_key_) - vector<size_t> localIndices; + std::vector<size_t> localIndices; // index of ghost nodes in local vector of keys (node_index_to_key_) - vector<size_t> ghostIndices; + std::vector<size_t> ghostIndices; localIndices.reserve(meshNodes_.size() - noof_ghosts_); ghostIndices.reserve(noof_ghosts_); @@ -136,9 +137,9 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { } // global keys of local nodes before renumbering - vector<unsigned int> oldGlobalKeysOfLocalNodes; + std::vector<unsigned int> oldGlobalKeysOfLocalNodes; // global keys of ghost nodes before renumbering - vector<unsigned int> oldGlobalKeysOfGhostNodes; + std::vector<unsigned int> oldGlobalKeysOfGhostNodes; // node_index_to_key_[i] tells the node at ith index oldGlobalKeysOfLocalNodes.reserve(localIndices.size()); @@ -161,12 +162,12 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { oldGlobalKeysOfGhostNodes.push_back( static_cast<unsigned int>(node_index_to_key_[ghost_index])); - ghostNodeOffsets_.push_back(filled_array<_node_>(0.0)); + ghostNodeOffsets_.push_back(std::filled_array<_node_>(0.0)); } } // new order of local indices based on current indices - vector<size_t> newLocalOrderOfIndices; + std::vector<size_t> newLocalOrderOfIndices; newLocalOrderOfIndices.reserve(meshNodes_.size()); newLocalOrderOfIndices.insert(newLocalOrderOfIndices.end(), @@ -177,9 +178,9 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { make_move_iterator(ghostIndices.begin()), make_move_iterator(ghostIndices.end())); - vector<size_t> newIndexOfOldIndex(newLocalOrderOfIndices.size()); + std::vector<size_t> newIndexOfOldIndex(newLocalOrderOfIndices.size()); - vector<size_t> reorderedIndexToKeys; + std::vector<size_t> reorderedIndexToKeys; reorderedIndexToKeys.reserve(meshNodes_.size()); @@ -196,7 +197,7 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { node_index_to_key_.swap(reorderedIndexToKeys); - vector<size_t>().swap(reorderedIndexToKeys); + std::vector<size_t>().swap(reorderedIndexToKeys); // change the actual localMeshIndex of the nodes for (auto &keyNodePair : meshNodes_) { @@ -219,7 +220,7 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { // changes // get the total number of unique nodes - vector<int> noofLocalNodesAllRanks(mpi_size); + std::vector<int> noofLocalNodesAllRanks(mpi_size); mpi_utilities::ALLGATHER<int>(static_cast<int>(localIndices.size()), noofLocalNodesAllRanks); @@ -227,12 +228,13 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { const unsigned int noofGlobalNodes = accumulate( noofLocalNodesAllRanks.begin(), noofLocalNodesAllRanks.end(), 0); - vector<unsigned int> globalKeyDistribution(noofGlobalNodes); + std::vector<unsigned int> globalKeyDistribution(noofGlobalNodes); - // vector<unsigned int> oldGlobalKeysToDistributedIndices(noofGlobalNodes); - unordered_map<unsigned int, unsigned int> oldGlobalKeysToDistributedIndices; + // std::vector<unsigned int> oldGlobalKeysToDistributedIndices(noofGlobalNodes); + std::unordered_map<unsigned int, unsigned int> + oldGlobalKeysToDistributedIndices; - vector<int> displacements(mpi_size, 0); + std::vector<int> displacements(mpi_size, 0); for (int i_rank = 1; i_rank != mpi_size; ++i_rank) { displacements[i_rank] = @@ -254,7 +256,7 @@ void KSimplexDMesh<D, K>::renumberMeshNodes(bool deleteVec) { // globalKeyDistribution[global_id_ctr]] = global_id_ctr; oldGlobalKeysToDistributedIndices.insert( - make_pair(globalKeyDistribution[global_id_ctr], global_id_ctr)); + std::make_pair(globalKeyDistribution[global_id_ctr], global_id_ctr)); } // these globalIndices allow accessing ghost nodes diff --git a/src/mesh/subMeshFromSubset.ipp b/src/mesh/subMeshFromSubset.ipp index b1aa1a42a..6506f6db9 100644 --- a/src/mesh/subMeshFromSubset.ipp +++ b/src/mesh/subMeshFromSubset.ipp @@ -6,7 +6,7 @@ \author P. Gupta */ #pragma once - +#include "qcMesh.h" namespace meshing { /** * this subroutine requires vertex adjacencies of parent mesh @@ -17,10 +17,10 @@ template <int D, int K, int NIDOF, typename repatomContainer, typename samplingAtomContainer> inline void KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: - buildSubMeshFromSubset(const vector<int> &_subset_simplex_ids, + buildSubMeshFromSubset(const std::vector<int> &_subset_simplex_ids, // we need ranks of nodes also - const vector<int> &_ranks_of_simplices, - const vector<int> &_node_material_indices, + const std::vector<int> &_ranks_of_simplices, + const std::vector<int> &_node_material_indices, const int &_owner_rank, const int &_total_owners, const Base &_parent_mesh) { @@ -32,15 +32,15 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: * 5. */ - typedef typename unordered_map<size_t, typename Base::_simplexNode_>::iterator - nodeIt; + typedef typename std::unordered_map< + size_t, typename Base::_simplexNode_>::iterator nodeIt; typedef DerefIterator<nodeIt, point<D>> pointLocator; typedef Box<point<D>, D> box; - unordered_map<size_t, bool> added_nodes; + std::unordered_map<size_t, bool> added_nodes; - unordered_map<size_t, size_t> added_nodes_local_indices_; + std::unordered_map<size_t, size_t> added_nodes_local_indices_; _ind_simplex_ simplex; @@ -49,7 +49,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: material_idx_of_nodes_.reserve(_parent_mesh.meshNodes_.size()); - vector<size_t> localToOldGlobalIndices; + std::vector<size_t> localToOldGlobalIndices; localToOldGlobalIndices.reserve(_parent_mesh.meshNodes_.size()); typename Base::_simplexCell_ cell; @@ -82,10 +82,10 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: _node_material_indices[cell[d].second]); } - cell.setNode(make_pair(mpi_rank, cell[d].second), d); + cell.setNode(std::make_pair(mpi_rank, cell[d].second), d); } - cell.setPairKey(make_pair(mpi_rank, simplex_key)); + cell.setPairKey(std::make_pair(mpi_rank, simplex_key)); Base::meshCells_.insert(make_pair(simplex_key, cell)); @@ -134,9 +134,9 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // <<Base::meshNodes_.at(Base::meshCells_.at(si)[d].second).getPoint()<<endl; // } - // vector<_node_> ringNodes; - // vector<size_t> ringIds; - // vector<_pairKey_> incidentElements; + // std::vector<_node_> ringNodes; + // std::vector<size_t> ringIds; + // std::vector<_pairKey_> incidentElements; // edge.first = Base::meshCells_.at(si).getPairKey(); // edge.second = 0; // edge.third = 1; @@ -147,9 +147,9 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: // bool onBoundary = Base::getIncidentCellsInOrder(edge, // std::back_inserter(incidentElements), ringNodes, ringIds); - // unordered_map<size_t, _ind_simplex_> outputTets; - // unordered_map<size_t, _node_> outputNodes; - // unordered_map<size_t, int> ranksOutputTets; + // std::unordered_map<size_t, _ind_simplex_> outputTets; + // std::unordered_map<size_t, _node_> outputNodes; + // std::unordered_map<size_t, int> ranksOutputTets; // Base::getSimplicesFromCells(incidentElements.begin(), // incidentElements.end(), outputTets, @@ -201,7 +201,7 @@ KSimplexDMesh_QC<D, K, NIDOF, repatomContainer, samplingAtomContainer>:: { for(size_t ind : Base::connected_nodes_[i_proc]) { - for(vector<size_t>::iterator local_it= + for(std::vector<size_t>::iterator local_it= Base::vertex_adj_pointers_[ind]; local_it!= Base::vertex_adj_pointers_[ind+1]; ++local_it) diff --git a/src/mesh/triangulation.h b/src/mesh/triangulation.h index 7c59a368b..181ff76c4 100644 --- a/src/mesh/triangulation.h +++ b/src/mesh/triangulation.h @@ -17,9 +17,6 @@ #include "definitions.h" #include "vtkIO.h" -using namespace std; -using namespace geometry; - namespace triangulation { template <int DIM> class Triangulation {}; @@ -30,16 +27,16 @@ public: double volume; CgalTriangulation_2 triangulation; - void CreateTriangulationOverPoints(vector<CGAL_POINT_2> coordinates) { + void CreateTriangulationOverPoints(std::vector<CGAL_POINT_2> coordinates) { this->volume = 0.0; - vector<pair<CGAL_POINT_2, int>> cgalPairs(coordinates.size()); + std::vector<std::pair<CGAL_POINT_2, int>> cgalPairs(coordinates.size()); int idx = 0; for (CGAL_POINT_2 p : coordinates) { // CGAL_POINT cp; // SetCoordinateVectorsCgalpoint<DIM>(cp, p.Coordinates); - cgalPairs[idx] = make_pair(p, idx); + cgalPairs[idx] = std::make_pair(p, idx); idx++; } @@ -50,9 +47,9 @@ public: int i_cell = 0; double element_volume; - vector<CGAL_POINT_2> vertices; - vector<CGAL_POINT_2> vertices_p; - vector<int> ZeroVolumeMarkers; + std::vector<CGAL_POINT_2> vertices; + std::vector<CGAL_POINT_2> vertices_p; + std::vector<int> ZeroVolumeMarkers; for (CgalFiniteCellsIterator_2 Cgalcell = triangulation.finite_faces_begin(); @@ -90,14 +87,14 @@ public: double volume; CgalTriangulation_3 triangulation; - void CreateTriangulationOverPoints(vector<CGAL_POINT_3> coordinates) { - vector<pair<CGAL_POINT_3, int>> cgalPairs(coordinates.size()); + void CreateTriangulationOverPoints(std::vector<CGAL_POINT_3> coordinates) { + std::vector<std::pair<CGAL_POINT_3, int>> cgalPairs(coordinates.size()); int idx = 0; for (CGAL_POINT_3 p : coordinates) { // CGAL_POINT cp; // SetCoordinateVectorsCgalpoint<DIM>(cp, p.Coordinates); - cgalPairs[idx] = make_pair(p, idx); + cgalPairs[idx] = std::make_pair(p, idx); idx++; } triangulation.insert(cgalPairs.begin(), cgalPairs.end()); @@ -107,9 +104,9 @@ public: int i_cell = 0; double element_volume; - vector<CGAL_POINT_3> vertices; - vector<CGAL_POINT_3> vertices_p; - vector<int> ZeroVolumeMarkers; + std::vector<CGAL_POINT_3> vertices; + std::vector<CGAL_POINT_3> vertices_p; + std::vector<int> ZeroVolumeMarkers; for (CgalFiniteCellsIterator_3 Cgalcell = triangulation.finite_cells_begin(); @@ -144,15 +141,16 @@ public: }; template <typename point_d, int DIM> -void ConstrainedDelaunay(const vector<point_d> &_enclosing_polygon, - const vector<point_d> &_nodes, - const array<point_d, DIM + 1> &_simplex); +void ConstrainedDelaunay(const std::vector<point_d> &_enclosing_polygon, + const std::vector<point_d> &_nodes, + const std::array<point_d, DIM + 1> &_simplex); template <> void ConstrainedDelaunay<point<2>, 2>( - const vector<point<2>> &_enclosing_polygon, const vector<point<2>> &_nodes, - const array<point<2>, 2 + 1> &_simplex) { - vector<pair<CGAL_POINT_2, int>> cgalPairs(_nodes.size()); + const std::vector<point<2>> &_enclosing_polygon, + const std::vector<point<2>> &_nodes, + const std::array<point<2>, 2 + 1> &_simplex) { + std::vector<std::pair<CGAL_POINT_2, int>> cgalPairs(_nodes.size()); Polygon_2 enclosure; for (point<2> point : _enclosing_polygon) { @@ -161,7 +159,7 @@ void ConstrainedDelaunay<point<2>, 2>( int idx = 0; for (point<2> point : _nodes) { - cgalPairs[idx] = make_pair(CGAL_POINT_2(point[0], point[1]), idx); + cgalPairs[idx] = std::make_pair(CGAL_POINT_2(point[0], point[1]), idx); idx++; } @@ -178,30 +176,33 @@ void ConstrainedDelaunay<point<2>, 2>( for (CgalConstrainedVertexIterator_2 CgalVertex = constrained_triangulation.vertices_begin(); CgalVertex != constrained_triangulation.vertices_end(); ++CgalVertex) { - cout << CgalVertex->info() << " , " - << constrained_triangulation.is_infinite(CgalVertex) << " , " - << CgalVertex->point() << endl; + std::cout << CgalVertex->info() << " , " + << constrained_triangulation.is_infinite(CgalVertex) << " , " + << CgalVertex->point() << std::endl; } for (CgalConstrainedFiniteCellsIterator_2 face = constrained_triangulation.finite_faces_begin(); face != constrained_triangulation.finite_faces_end(); ++face) { for (int nd = 0; nd < 3; nd++) { - cout << face->vertex(nd)->info() << " , "; + std::cout << face->vertex(nd)->info() << " , "; } - cout << endl; + std::cout << std::endl; } - cout << "triangulated over " << cgalPairs.size() << " points" << endl; - cout << "total vertices used " - << constrained_triangulation.number_of_vertices() << endl; - cout << "total faces " << constrained_triangulation.number_of_faces() << endl; + std::cout << "triangulated over " << cgalPairs.size() << " points" + << std::endl; + std::cout << "total vertices used " + << constrained_triangulation.number_of_vertices() << std::endl; + std::cout << "total faces " << constrained_triangulation.number_of_faces() + << std::endl; } template <> void ConstrainedDelaunay<point<3>, 3>( - const vector<point<3>> &_enclosing_polygon, const vector<point<3>> &_nodes, - const array<point<3>, 3 + 1> &_simplex) { - vector<pair<CGAL_POINT_3, int>> cgalPairs(_nodes.size()); + const std::vector<point<3>> &_enclosing_polygon, + const std::vector<point<3>> &_nodes, + const std::array<point<3>, 3 + 1> &_simplex) { + std::vector<std::pair<CGAL_POINT_3, int>> cgalPairs(_nodes.size()); } } // namespace triangulation #endif diff --git a/src/mesh/triangulationToMesh.h b/src/mesh/triangulationToMesh.h index 6a0a79261..00ff13c7f 100644 --- a/src/mesh/triangulationToMesh.h +++ b/src/mesh/triangulationToMesh.h @@ -13,17 +13,17 @@ class CGALToMeshConverter {}; template <typename mesh_d, typename point_d> class CGALToMeshConverter<2, mesh_d, point_d> { public: - void BuildMeshFromCgalTriangulation(const vector<point_d> &, mesh_d &, - CgalTriangulation_2, vector<int>); + void BuildMeshFromCgalTriangulation(const std::vector<point_d> &, mesh_d &, + CgalTriangulation_2, std::vector<int>); }; template <typename mesh_d, typename point_d> class CGALToMeshConverter<3, mesh_d, point_d> { public: - void BuildMeshFromCgalTriangulation(const vector<point_d> &, mesh_d &, + void BuildMeshFromCgalTriangulation(const std::vector<point_d> &, mesh_d &, CgalTriangulation_3, - vector<int> _material_idx); + std::vector<int> _material_idx); }; } // namespace meshing -#include "triangulationToMesh.ipp" \ No newline at end of file +#include "triangulationToMesh.ipp" diff --git a/src/mesh/triangulationToMesh.ipp b/src/mesh/triangulationToMesh.ipp index 1ffe753e4..af0ec1b16 100644 --- a/src/mesh/triangulationToMesh.ipp +++ b/src/mesh/triangulationToMesh.ipp @@ -365,24 +365,27 @@ // _global_mesh.ShuffleAllElements(); // } +#pragma once +#include "triangulationToMesh.h" + template <typename mesh_d, typename point_d> void meshing::CGALToMeshConverter<3, mesh_d, point_d>:: - BuildMeshFromCgalTriangulation(const vector<point_d> &_meshpoints, + BuildMeshFromCgalTriangulation(const std::vector<point_d> &_meshpoints, mesh_d &_global_mesh, CgalTriangulation_3 _triangulationhandle, - vector<int> _material_idx) { + std::vector<int> _material_idx) { - typedef array<size_t, 3 + 1> Simplex; + typedef std::array<size_t, 3 + 1> Simplex; - vector<Simplex> global_simplices; - // vector<int> node_material_indices(_meshpoints.size(), 0); + std::vector<Simplex> global_simplices; + // std::vector<int> node_material_indices(_meshpoints.size(), 0); - array<point_d, 3 + 1> simplex_coordinates; - array<int, 3 + 1> simplex_vertex_material_idx; + std::array<point_d, 3 + 1> simplex_coordinates; + std::array<int, 3 + 1> simplex_vertex_material_idx; int illegal_elements = 0; - vector<int> degenerate_markers; + std::vector<int> degenerate_markers; for (CgalFiniteCellsIterator_3 Cgalcell = _triangulationhandle.finite_cells_begin(); @@ -407,7 +410,7 @@ void meshing::CGALToMeshConverter<3, mesh_d, point_d>:: 6.0; if (volume < 0.0) { - swap(simplex[1], simplex[2]); + std::swap(simplex[1], simplex[2]); } global_simplices.push_back(simplex); } @@ -415,11 +418,11 @@ void meshing::CGALToMeshConverter<3, mesh_d, point_d>:: // say, we maintain an unordered map of elements and nodes // simplices.at(key) -> simplex object // nodes.at(key) -> node (coordinate) - // vector<vector<simplex>> halo_simplices_ - // vector<vector<node>> halo_nodes_ + // std::vector<std::vector<simplex>> halo_simplices_ + // std::vector<std::vector<node>> halo_nodes_ // - // simplex object has neighbours (array<<pair<int, size_t>, DIM+1>) - // simplex object has nodes (array<<pair<int, size_t>, DIM+1>) + // simplex object has neighbours (std::array<<pair<int, size_t>, DIM+1>) + // simplex object has nodes (std::array<<pair<int, size_t>, DIM+1>) // neighbours and nodes are essentially, (rank, key) // if(rank == mpi_rank), then access from simplices.at(key) // else, access halo_simplices_[rank][key] @@ -430,4 +433,4 @@ void meshing::CGALToMeshConverter<3, mesh_d, point_d>:: // we make the faces using indexed simplices directly. _global_mesh.build(_meshpoints, global_simplices); -} \ No newline at end of file +} diff --git a/src/mesh/uniformDistributeMesh.ipp b/src/mesh/uniformDistributeMesh.ipp index a414d411a..bddee2628 100644 --- a/src/mesh/uniformDistributeMesh.ipp +++ b/src/mesh/uniformDistributeMesh.ipp @@ -13,27 +13,27 @@ namespace meshing { template <int D, int K> template <typename MeshType> void KSimplexDMesh<D, K>::uniformDistributionToLocalMesh( - MeshType &_local_mesh, const vector<int> &_materialIds) { - array<size_t, K + 1> simplexNodeKeys; + MeshType &_local_mesh, const std::vector<int> &_materialIds) { + std::array<size_t, K + 1> simplexNodeKeys; - vector<array<size_t, K + 1>> elementsPartition; - vector<_node_> nodesPartition; - vector<size_t> nodesIDsPartition; - vector<int> materialIDsPartition; + std::vector<std::array<size_t, K + 1>> elementsPartition; + std::vector<_node_> nodesPartition; + std::vector<size_t> nodesIDsPartition; + std::vector<int> materialIDsPartition; - vector<int> countElements(mpi_size, 0); - vector<int> countNodes(mpi_size, 0); + std::vector<int> countElements(mpi_size, 0); + std::vector<int> countNodes(mpi_size, 0); int noofElements, noofNodes; - vector<int> rankElementDelimiters(mpi_size + 1, 0); + std::vector<int> rankElementDelimiters(mpi_size + 1, 0); - vector<int> rankElementDisplacements(mpi_size, 0); - vector<int> rankNodeDisplacements(mpi_size, 0); + std::vector<int> rankElementDisplacements(mpi_size, 0); + std::vector<int> rankNodeDisplacements(mpi_size, 0); size_t rank_size, nodeKey; if (mpi_rank == 0) { - vector<bool> added_node(meshNodes_.size(), false); + std::vector<bool> added_node(meshNodes_.size(), false); for (size_t i = 0; i < mpi_size; i++) { rankElementDelimiters[i] = i * size_t(meshCells_.size() / mpi_size); @@ -77,10 +77,10 @@ void KSimplexDMesh<D, K>::uniformDistributionToLocalMesh( } } - vector<size_t> localNodeIDs; - vector<int> localNodesMaterialIDs; - vector<_node_> localNodes; - vector<array<size_t, K + 1>> localElements; + std::vector<size_t> localNodeIDs; + std::vector<int> localNodesMaterialIDs; + std::vector<_node_> localNodes; + std::vector<std::array<size_t, K + 1>> localElements; mpi_utilities::BCAST(countElements, 0); mpi_utilities::BCAST(countNodes, 0); @@ -111,7 +111,7 @@ void KSimplexDMesh<D, K>::uniformDistributionToLocalMesh( countNodes, rankNodeDisplacements, noofNodes, 0); - mpi_utilities::SCATTERV_CUSTOM<array<size_t, K + 1>, K + 1>( + mpi_utilities::SCATTERV_CUSTOM<std::array<size_t, K + 1>, K + 1>( elementsPartition, localElements, countElements, rankElementDisplacements, noofElements, 0); @@ -122,4 +122,4 @@ void KSimplexDMesh<D, K>::uniformDistributionToLocalMesh( _local_mesh.renumberCells(); } -} // namespace meshing \ No newline at end of file +} // namespace meshing diff --git a/src/neighbourhoods/AddForcesToAllRepatoms.ipp b/src/neighbourhoods/AddForcesToAllRepatoms.ipp index b668bc577..e800d033b 100644 --- a/src/neighbourhoods/AddForcesToAllRepatoms.ipp +++ b/src/neighbourhoods/AddForcesToAllRepatoms.ipp @@ -1,18 +1,20 @@ #pragma once +#include "neighbourhoods_global.h" template <typename point_d, typename Vector_d, typename ball_d, typename mesh_d, typename sampling_atom, typename repatom, typename vtkWriter, int DIM> void neighbourhoods::ArrangeNeighboursAndAddForces( - vector<sampling_atom> &_sampling_atoms, vector<repatom> &_repatoms, - mesh_d &_local_mesh, const mesh_d &_global_mesh, - const vector<material<DIM> *> &_materials) { + std::vector<sampling_atom> &_sampling_atoms, + std::vector<repatom> &_repatoms, mesh_d &_local_mesh, + const mesh_d &_global_mesh, + const std::vector<material<DIM> *> &_materials) { typedef neighbourhoods::InterProcNeighbourData InterProcNeighbourConnectivity; typedef neighbourhoods::SamplingAtomRelayQuery<point_d> InterProcRelayQuery; MPI_Barrier(MPI_COMM_WORLD); - cout << "rank : " << mpi_rank << " resetting and adding element lattice sites" - << endl; + std::cout << "rank : " << mpi_rank + << " resetting and adding element lattice sites" << std::endl; neighbourhoods::ResetAllLatticeSites<mesh_d, DIM>(_local_mesh); neighbourhoods::ResetAllNeighbourDependecies<sampling_atom, DIM>( @@ -22,34 +24,36 @@ void neighbourhoods::ArrangeNeighboursAndAddForces( neighbourhoods::AddElementLatticeSites<point_d, mesh_d>(_local_mesh, _materials); - cout << "rank : " << mpi_rank - << " reset elements. Computing local neighbourhoods" << endl; + std::cout << "rank : " << mpi_rank + << " reset elements. Computing local neighbourhoods" << std::endl; //************CALCULATING NEIGHBOURHOODS OF SAMPLING ATOMS*************// //***********CALCULATING ENERGIES OF SAMPLING ATOMS AND FORCES ON //REP-ATOMS****// MPI_Barrier(MPI_COMM_WORLD); - vector<vector<InterProcRelayQuery>> sampling_atom_relay_queries_send; + std::vector<std::vector<InterProcRelayQuery>> + sampling_atom_relay_queries_send; neighbourhoods::AssembleNeighbourhoodsLocalToProc<point_d, mesh_d, ball_d, sampling_atom, DIM>( _local_mesh, _global_mesh, _materials, _sampling_atoms, sampling_atom_relay_queries_send); - cout << "rank : " << mpi_rank - << " built local neighbourhoods. Exchanging interproc neighbourhoods " - << endl; + std::cout + << "rank : " << mpi_rank + << " built local neighbourhoods. Exchanging interproc neighbourhoods " + << std::endl; // MPI_Barrier (MPI_COMM_WORLD); - // vector<vector<InterProcNeighbourConnectivity>> + // std::vector<std::vector<InterProcNeighbourConnectivity>> // other_proc_samplingatoms_neighbourhood_connectivity; - // vector<vector<int>> unique_neighbours_other_procs_sampling_atoms; - // vector<vector<int>> unique_neighbours_connected_sampling_atoms; + // std::vector<std::vector<int>> unique_neighbours_other_procs_sampling_atoms; + // std::vector<std::vector<int>> unique_neighbours_connected_sampling_atoms; - // vector<vector<int>> noof_neighbours_other_proc_sampling_atoms; - // vector<vector<int>> noof_neighbours_connected_sampling_atoms; + // std::vector<std::vector<int>> noof_neighbours_other_proc_sampling_atoms; + // std::vector<std::vector<int>> noof_neighbours_connected_sampling_atoms; // if(mpi_size > 1) // { @@ -62,8 +66,8 @@ void neighbourhoods::ArrangeNeighboursAndAddForces( // unique_neighbours_other_procs_sampling_atoms, // unique_neighbours_connected_sampling_atoms); - // cout<<"rank : "<<mpi_rank<<" exchanged interproc - // neighbourhoods"<<endl; + // std::cout<<"rank : "<<mpi_rank<<" exchanged interproc + // neighbourhoods"<<std::endl; // MPI_Barrier (MPI_COMM_WORLD); // } @@ -90,4 +94,4 @@ void neighbourhoods::ArrangeNeighboursAndAddForces( // noof_neighbours_connected_sampling_atoms, // unique_neighbours_connected_sampling_atoms); // } -} \ No newline at end of file +} diff --git a/src/neighbourhoods/CalculatePotentialsAndForces.ipp b/src/neighbourhoods/CalculatePotentialsAndForces.ipp index 8c1c78ec3..323bf8b5c 100644 --- a/src/neighbourhoods/CalculatePotentialsAndForces.ipp +++ b/src/neighbourhoods/CalculatePotentialsAndForces.ipp @@ -1,11 +1,13 @@ #pragma once +#include "neighbourhoods_global.h" #include <chrono> template <typename Point_d, typename sampling_atom, int DIM> void neighbourhoods::CalcPairPotentialAndForce( - const vector<material<DIM> *> &_materials, vector<sampling_atom> &_atoms) { + const std::vector<material<DIM> *> &_materials, + std::vector<sampling_atom> &_atoms) { int neighbour_ctr = 0; double r_ij; @@ -29,7 +31,8 @@ void neighbourhoods::CalcPairPotentialAndForce( template <typename Point_d, typename sampling_atom, int DIM> void neighbourhoods::CalcEmbeddingPotentialAndForce( - const vector<material<DIM> *> &_materials, vector<sampling_atom> &_atoms) { + const std::vector<material<DIM> *> &_materials, + std::vector<sampling_atom> &_atoms) { int neighbour_ctr; double rho_e, r_ij, df_rho; @@ -59,7 +62,7 @@ void neighbourhoods::CalcEmbeddingPotentialAndForce( template <typename Vector_d, typename Point_d, typename sampling_atom, int DIM> void neighbourhoods::CalcForceVectorsEachNeighbour( - vector<sampling_atom> &_atoms) { + std::vector<sampling_atom> &_atoms) { Vector_d r_ij; int neighbour_ctr; for (sampling_atom &atom : _atoms) { @@ -78,8 +81,9 @@ void neighbourhoods::CalcForceVectorsEachNeighbour( } template <typename Vector_d, typename sampling_atom, typename repatom, int DIM> -void neighbourhoods::AddForceToRepAtoms(vector<sampling_atom> &_sampling_atoms, - vector<repatom> &_local_repatoms) { +void neighbourhoods::AddForceToRepAtoms( + std::vector<sampling_atom> &_sampling_atoms, + std::vector<repatom> &_local_repatoms) { int dependent_repatom; // for(int repatom_id=0; repatom_id<_local_repatoms.size(); repatom_id++) @@ -164,13 +168,16 @@ void neighbourhoods::AddForceToRepAtoms(vector<sampling_atom> &_sampling_atoms, template <typename Point_d, typename Vector_d, typename mesh_d, typename sampling_atom, typename repatom, int DIM> void neighbourhoods::AddForceToInterProcRepAtoms( - vector<sampling_atom> &_sampling_atoms, vector<repatom> &_local_repatoms, - const mesh_d &_mesh, - const vector<vector<neighbourhoods::InterProcNeighbourData>> + std::vector<sampling_atom> &_sampling_atoms, + std::vector<repatom> &_local_repatoms, const mesh_d &_mesh, + const std::vector<std::vector<neighbourhoods::InterProcNeighbourData>> &_connected_repatoms_other_proc_sampling_atoms, - const vector<vector<int>> &_number_of_neighbours_other_proc_sampling_atoms, - const vector<vector<int>> &_number_of_neighbours_connected_sampling_atoms, - const vector<vector<int>> &_unique_neighbours_connected_sampling_atoms) { + const std::vector<std::vector<int>> + &_number_of_neighbours_other_proc_sampling_atoms, + const std::vector<std::vector<int>> + &_number_of_neighbours_connected_sampling_atoms, + const std::vector<std::vector<int>> + &_unique_neighbours_connected_sampling_atoms) { // All NeighbourForces_magnitudes are stored in sampling atoms. // Send the unique neighbours forces to other procs int idx_atom; @@ -178,9 +185,9 @@ void neighbourhoods::AddForceToInterProcRepAtoms( int neighbour_idx; double f_mag; - vector<vector<double>> ForcesConnectedNeighbours( + std::vector<std::vector<double>> ForcesConnectedNeighbours( _mesh.SendingProcs_SamplingAtoms.size()); - vector<vector<double>> ForcesOtherProcNeighbours( + std::vector<std::vector<double>> ForcesOtherProcNeighbours( _mesh.ReceivingProcs_SamplingAtoms.size()); // Vector_d r_ij; @@ -225,7 +232,7 @@ void neighbourhoods::AddForceToInterProcRepAtoms( int force_ctr; int dependent_bond_id; Vector_d f_ij; - pair<Point_d, Point_d> dependent_bond; + std::pair<Point_d, Point_d> dependent_bond; for (int i_proc = 0; i_proc < _mesh.ReceivingProcs_SamplingAtoms.size(); i_proc++) { @@ -267,7 +274,7 @@ void neighbourhoods::AddForceToInterProcRepAtoms( .DependentRepAtoms[i_n][dependent_ctr]; bool added = - Utilities::ADD_TO_CONTAINER_UNIQUE<pair<Point_d, Point_d>>( + Utilities::ADD_TO_CONTAINER_UNIQUE<std::pair<Point_d, Point_d>>( _local_repatoms[dependent_repatom].dependent_neighbour_bonds_, dependent_bond, dependent_bond_id); @@ -302,14 +309,14 @@ void neighbourhoods::AddForceToInterProcRepAtoms( // Exchange the neighbour bonds among connected // nodes. Assemble the points of bonds - vector<vector<double>> neighbour_bonds_weights_send_buffer; - vector<vector<double>> neighbour_bonds_weights_recv_buffer; + std::vector<std::vector<double>> neighbour_bonds_weights_send_buffer; + std::vector<std::vector<double>> neighbour_bonds_weights_recv_buffer; - // vector<vector<double>> neighbour_bond_weights_send_buffer; - // vector<vector<double>> neighbour_bond_weights_recv_buffer; + // std::vector<std::vector<double>> neighbour_bond_weights_send_buffer; + // std::vector<std::vector<double>> neighbour_bond_weights_recv_buffer; - vector<vector<int>> number_of_neighbour_bonds_send_buffer; - vector<vector<int>> number_of_neighbour_bonds_recv_buffer; + std::vector<std::vector<int>> number_of_neighbour_bonds_send_buffer; + std::vector<std::vector<int>> number_of_neighbour_bonds_recv_buffer; mpi_utilities::PackSendBuffers_DependentBonds<repatom, Point_d, DIM>( _local_repatoms, _mesh.ConnectedProcs, _mesh.ConnectedNodes, @@ -343,4 +350,4 @@ void neighbourhoods::AddForceToInterProcRepAtoms( number_of_neighbour_bonds_recv_buffer, _mesh.ConnectedNodes); // Adding correction of forces due to -} \ No newline at end of file +} diff --git a/src/neighbourhoods/bruteForceNeighbourCheck.ipp b/src/neighbourhoods/bruteForceNeighbourCheck.ipp index 051bb308e..dfae7fab8 100644 --- a/src/neighbourhoods/bruteForceNeighbourCheck.ipp +++ b/src/neighbourhoods/bruteForceNeighbourCheck.ipp @@ -7,8 +7,7 @@ Zurich, Mechanics and Materials Lab */ #pragma once - -using namespace geometry; +#include "neighbourhoods.h" template <typename InputClass, typename mesh, typename externalForceApplicator, typename filewriter, int DIM, int NIDOF> @@ -16,23 +15,24 @@ void neighbourhoods::bruteForceNeighbourCheck( const InputClass &_inputParams, mesh &_local_mesh, externalForceApplicator *_externalForceApplicator, const Box<point<DIM>, DIM> &_domain_bounds, - const vector<material<DIM> *> &_materials, + const std::vector<material<DIM> *> &_materials, const bool &_applyExternalForce) { neighbourhoods::ComputePotential<mesh, DIM, NIDOF>(_local_mesh, _materials); - vector<double> oldNodalEnergies = _local_mesh.samplingAtoms.nodalEnergies_; + std::vector<double> oldNodalEnergies = + _local_mesh.samplingAtoms.nodalEnergies_; - vector<double> oldCentralEnergies = + std::vector<double> oldCentralEnergies = _local_mesh.samplingAtoms.centralEnergies_; // store neighbours and number of neighbours - vector<int> noof_neighbours_nodal_sampling_atoms( + std::vector<int> noof_neighbours_nodal_sampling_atoms( _local_mesh.samplingAtoms.nodalLocations_.size() - _local_mesh.noof_ghosts_, 0); - vector<int> noof_neighbours_cb_sampling_atoms( + std::vector<int> noof_neighbours_cb_sampling_atoms( _local_mesh.samplingAtoms.centralLocations_.size()); for (size_t nodeIndex = 0; @@ -68,10 +68,10 @@ void neighbourhoods::bruteForceNeighbourCheck( // } } - vector<size_t> triggered_meshExchange_sampling_atoms; - vector<size_t> triggered_periodicMeshExchange_sampling_atoms; - vector<size_t> triggered_nodal_sampling_atoms; - vector<size_t> triggered_cb_sampling_atoms; + std::vector<size_t> triggered_meshExchange_sampling_atoms; + std::vector<size_t> triggered_periodicMeshExchange_sampling_atoms; + std::vector<size_t> triggered_nodal_sampling_atoms; + std::vector<size_t> triggered_cb_sampling_atoms; triggered_nodal_sampling_atoms.reserve( _local_mesh.samplingAtoms.nodalLocations_.size() - @@ -183,4 +183,4 @@ void neighbourhoods::bruteForceNeighbourCheck( cout << mpi_rank << " , had different potential energy; nodal : " << faultyNodeNeighbours << " , central : " << faultyCentralNeighbours << endl; -} \ No newline at end of file +} diff --git a/src/neighbourhoods/getEntropyRates.ipp b/src/neighbourhoods/getEntropyRates.ipp index 615988bb0..0f45b94f5 100644 --- a/src/neighbourhoods/getEntropyRates.ipp +++ b/src/neighbourhoods/getEntropyRates.ipp @@ -7,13 +7,12 @@ */ #pragma once -using namespace std; -using namespace geometry; +#include "neighbourhoods.h" template <typename mesh, int DIM> void neighbourhoods::EntropyRateOnsagerKinetics( mesh &_local_mesh, double &_dt_min, - const vector<material<DIM> *> &_materials) { + const std::vector<material<DIM> *> &_materials) { // A_onsager for copper from conductivity at room temperature // kappa = 401 W/m.K @@ -43,11 +42,11 @@ void neighbourhoods::EntropyRateOnsagerKinetics( double dt_inv_sampling_atom, dt_inv_max_local, dt_inv_max_global; - array<size_t, DIM + 1> indexedSimplex; + std::array<size_t, DIM + 1> indexedSimplex; - vector<point<DIM>> cluster; - vector<array<double, NIDOF>> clusterThermalCoordinates; - vector<int> neighbourIndices; + std::vector<point<DIM>> cluster; + std::vector<std::array<double, NIDOF>> clusterThermalCoordinates; + std::vector<int> neighbourIndices; // T_i\dot{s}_i = \sum_{j}A_{ij} T^2_{ij} \left(1/_T{i} - 1/T_{j}\right) // use force based type entropy rates coarsening diff --git a/src/neighbourhoods/getForceAndPotential.ipp b/src/neighbourhoods/getForceAndPotential.ipp index 2f85e1d49..56f092aee 100644 --- a/src/neighbourhoods/getForceAndPotential.ipp +++ b/src/neighbourhoods/getForceAndPotential.ipp @@ -7,26 +7,25 @@ */ #pragma once - -using namespace geometry; +#include "neighbourhoods.h" template <typename mesh, int DIM, int NIDOF> void neighbourhoods::AddThermalizedForcesToRepatoms_3( - mesh &_local_mesh, const vector<material<DIM> *> &_materials) { + mesh &_local_mesh, const std::vector<material<DIM> *> &_materials) { typedef lattice::latticeSite<DIM, NIDOF> neighbour_site; - vector<double> overlapping_nodes_forces_data_send_1D; - vector<double> overlapping_nodes_forces_data_recv_1D; + std::vector<double> overlapping_nodes_forces_data_send_1D; + std::vector<double> overlapping_nodes_forces_data_recv_1D; - vector<double> periodic_overlapping_forces_send_1D; - vector<double> periodic_overlapping_forces_recv_1D; + std::vector<double> periodic_overlapping_forces_send_1D; + std::vector<double> periodic_overlapping_forces_recv_1D; - vector<int> delimiters_send(mpi_size + 1, 0); - vector<int> delimiters_recv(mpi_size + 1, 0); + std::vector<int> delimiters_send(mpi_size + 1, 0); + std::vector<int> delimiters_recv(mpi_size + 1, 0); - vector<int> periodic_delimiters_send(mpi_size + 1, 0); - vector<int> periodic_delimiters_recv(mpi_size + 1, 0); + std::vector<int> periodic_delimiters_send(mpi_size + 1, 0); + std::vector<int> periodic_delimiters_recv(mpi_size + 1, 0); for (int i_proc = 1; i_proc < mpi_size + 1; i_proc++) { delimiters_send[i_proc] = @@ -80,8 +79,8 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( // interproc_repatom_idx, noof_quadrature_samples, // noof_scalars, displaced_point_index; - // vector<point<DIM>> sampling_atom_shifts; - // vector<point<DIM>> neighbour_shifts; + // std::vector<point<DIM>> sampling_atom_shifts; + // std::vector<point<DIM>> neighbour_shifts; // sampling_atom_shifts.reserve(200); // neighbour_shifts.reserve(200); @@ -100,27 +99,27 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( sampling_atom_clock.tic(); #ifdef MULTI_THREADING -#pragma omp declare reduction(vec_point_plus : std::vector<point<DIM>> : \ +#pragma omp declare reduction(vec_point_plus : std::std::vector<point<DIM>> : \ std::transform(omp_out.begin(), omp_out.end(), \ omp_in.begin(), omp_out.begin(), std::plus<point<DIM>>())) \ initializer(omp_priv = decltype(omp_orig)(omp_orig.size())) -#pragma omp declare reduction(vec_double_plus : std::vector<double> : \ +#pragma omp declare reduction(vec_double_plus : std::std::vector<double> : \ std::transform(omp_out.begin(), omp_out.end(), \ omp_in.begin(), omp_out.begin(), std::plus<double>())) \ initializer(omp_priv = decltype(omp_orig)(omp_orig.size())) #endif - vector<point<DIM>> forces(_local_mesh.repatoms.forces_.size(), - filled_array<point<DIM>>(0.0)); + std::vector<point<DIM>> forces(_local_mesh.repatoms.forces_.size(), + std::filled_array<point<DIM>>(0.0)); - vector<double> thermal_forces(_local_mesh.repatoms.forces_.size(), 0.0); + std::vector<double> thermal_forces(_local_mesh.repatoms.forces_.size(), 0.0); - array<size_t, DIM + 1> indexedSimplex; + std::array<size_t, DIM + 1> indexedSimplex; // first private copies into variables local to threads // every thread will have its interpolator - vector<material<DIM> *> firstPrivateMaterials; + std::vector<material<DIM> *> firstPrivateMaterials; firstPrivateMaterials = _local_mesh.qcMaterials_; #ifdef MULTI_THREADING @@ -134,7 +133,7 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( { point<DIM> f_ij, r_ij, quad_point, sampling_atom_shift, neighbour_shift; - // vector<point<DIM>> sampling_atom_shifts, neighbour_shifts; + // std::vector<point<DIM>> sampling_atom_shifts, neighbour_shifts; // sampling_atom_shifts.reserve(200); // neighbour_shifts.reserve(200); @@ -146,13 +145,13 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( noofDependencies; size_t local_repatom_idx, elementKeyCentralAtom, elementIndexCentralAtom; - vector<point<DIM>> clusterForces; - vector<double> clusterThermalForceSamplingAtom; - vector<double> clusterThermalForceNeighbour; - vector<int> neighbourIndices; + std::vector<point<DIM>> clusterForces; + std::vector<double> clusterThermalForceSamplingAtom; + std::vector<double> clusterThermalForceNeighbour; + std::vector<int> neighbourIndices; - vector<point<DIM>> cluster; - vector<array<double, NIDOF>> clusterThermalCoordinates; + std::vector<point<DIM>> cluster; + std::vector<std::array<double, NIDOF>> clusterThermalCoordinates; int neighbourIdx; @@ -331,12 +330,13 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( // ********************************************************** // if (std::isnan(magnitude(f_ij))) { - cout << "cb :" << magnitude(f_ij) << " , " - << _local_mesh.samplingAtoms - .centralSamplingAtomNeighbours_[atomIndex][neighbourIdx] - .thermal_coordinate_ - << " , " << _local_mesh.samplingAtoms.centralIDOFs_[atomIndex] - << endl; + std::cout + << "cb :" << magnitude(f_ij) << " , " + << _local_mesh.samplingAtoms + .centralSamplingAtomNeighbours_[atomIndex][neighbourIdx] + .thermal_coordinate_ + << " , " << _local_mesh.samplingAtoms.centralIDOFs_[atomIndex] + << std::endl; } } } @@ -491,7 +491,7 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( { point<DIM> f_ij, r_ij, quad_point, sampling_atom_shift, neighbour_shift; - // vector<point<DIM>> sampling_atom_shifts, neighbour_shifts; + // std::vector<point<DIM>> sampling_atom_shifts, neighbour_shifts; // sampling_atom_shifts.reserve(200); // neighbour_shifts.reserve(200); @@ -503,13 +503,13 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( noofDependencies; size_t local_repatom_idx; - vector<point<DIM>> clusterForces; - vector<double> clusterThermalForceSamplingAtom; - vector<double> clusterThermalForceNeighbour; - vector<int> neighbourIndices; + std::vector<point<DIM>> clusterForces; + std::vector<double> clusterThermalForceSamplingAtom; + std::vector<double> clusterThermalForceNeighbour; + std::vector<int> neighbourIndices; - vector<point<DIM>> cluster; - vector<array<double, NIDOF>> clusterThermalCoordinates; + std::vector<point<DIM>> cluster; + std::vector<std::array<double, NIDOF>> clusterThermalCoordinates; int neighbourIdx; @@ -724,19 +724,20 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( // neighbour_shifts[neighbourIdx])/double(DIM); if (std::isnan(magnitude(f_ij))) { - cout << "nodal : " << magnitude(f_ij) << " , " - << _local_mesh.samplingAtoms - .nodalSamplingAtomNeighbours_[atomIndex][neighbourIdx] - .thermal_coordinate_ - << " , " - << _local_mesh.repatoms.thermal_coordinates_[atomIndex] - << " , " - << _local_mesh.samplingAtoms - .nodalSamplingAtomNeighbours_[atomIndex][neighbourIdx] - .location_ - << " , " - << _local_mesh.samplingAtoms.nodalLocations_[atomIndex] - << endl; + std::cout + << "nodal : " << magnitude(f_ij) << " , " + << _local_mesh.samplingAtoms + .nodalSamplingAtomNeighbours_[atomIndex][neighbourIdx] + .thermal_coordinate_ + << " , " + << _local_mesh.repatoms.thermal_coordinates_[atomIndex] + << " , " + << _local_mesh.samplingAtoms + .nodalSamplingAtomNeighbours_[atomIndex][neighbourIdx] + .location_ + << " , " + << _local_mesh.samplingAtoms.nodalLocations_[atomIndex] + << std::endl; exit(0); } } @@ -916,10 +917,10 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( } } - // vector<vector<double>> connected_nodes_forces_data_send( + // std::vector<std::vector<double>> connected_nodes_forces_data_send( // _local_mesh.connected_node_procs_.size()); - // vector<vector<double>> connected_nodes_forces_data_recv( + // std::vector<std::vector<double>> connected_nodes_forces_data_recv( // _local_mesh.connected_node_procs_.size()); // for(int i_proc=0; i_proc<_local_mesh.connected_node_procs_.size(); @@ -1098,7 +1099,7 @@ void neighbourhoods::AddThermalizedForcesToRepatoms_3( template <typename sampling_atom, int DIM> void generateNeighbourhoodQuadratureClouds_3( const sampling_atom &_sampling_atom, const int &_noof_quadrature_samplings, - vector<point<DIM>> &_quad_points) { + std::vector<point<DIM>> &_quad_points) { // weights are calculated outside // (based on order and number of neighbours) @@ -1112,7 +1113,7 @@ void generateNeighbourhoodQuadratureClouds_3( double r = sqrt(0.5 * double(noof_scalars)); double r_sign; - vector<point<DIM>> neighbourVectors(noof_neighbours); + std::vector<point<DIM>> neighbourVectors(noof_neighbours); // store the amount of change, and index of neighbour // changed. These are sparse matrices. diff --git a/src/neighbourhoods/getRequiredNeighbourhoods.ipp b/src/neighbourhoods/getRequiredNeighbourhoods.ipp index 0f9024a3c..bcb7d2324 100644 --- a/src/neighbourhoods/getRequiredNeighbourhoods.ipp +++ b/src/neighbourhoods/getRequiredNeighbourhoods.ipp @@ -7,25 +7,24 @@ © 2020 ETH Zurich, Mechanics and Materials Lab */ #pragma once - -using namespace geometry; +#include "neighbourhoods.h" template <typename InputClass, typename mesh, int DIM, int NIDOF> void neighbourhoods::getRequiredNeighbourhoods( const InputClass &_inputParams, mesh &_local_mesh, - vector<size_t> &_marked_meshExchange_sampling_atoms, - vector<size_t> &_marked_periodicMeshExchange_sampling_atoms, - vector<size_t> &_marked_nodal_sampling_atoms, - vector<size_t> &_marked_cb_sampling_atoms, + std::vector<size_t> &_marked_meshExchange_sampling_atoms, + std::vector<size_t> &_marked_periodicMeshExchange_sampling_atoms, + std::vector<size_t> &_marked_nodal_sampling_atoms, + std::vector<size_t> &_marked_cb_sampling_atoms, const Box<point<DIM>, DIM> &_domain_bounds) { // ---------- < nodal sampling atoms >-----------------// // determine which marked nodal sampling atoms // might need more mesh. - typedef array<point<DIM>, DIM + 1> Simplex; - typedef array<int, DIM> Face; - typedef pair<int, int> PairDataIndex; - typedef Triplet<int, int, int> TripletDataIndex; + typedef std::array<point<DIM>, DIM + 1> Simplex; + typedef std::array<int, DIM> Face; + typedef std::pair<int, int> PairDataIndex; + typedef std::Triplet<int, int, int> TripletDataIndex; typedef lattice::uniqueLatticeSiteContainer<point<DIM>, DIM> uniquePointContainer; @@ -33,15 +32,16 @@ void neighbourhoods::getRequiredNeighbourhoods( typedef geom::Ball<double, DIM> ball; // make the marked sampling atom balls - vector<ball> local_sampling_atom_balls; - vector<ball> interproc_balls; - vector<ball> periodic_balls; + std::vector<ball> local_sampling_atom_balls; + std::vector<ball> interproc_balls; + std::vector<ball> periodic_balls; - vector<vector<size_t>> elements_of_sampling_atoms; + std::vector<std::vector<size_t>> elements_of_sampling_atoms; - vector<vector<PairDataIndex>> periodic_elements_of_sampling_atoms; - vector<vector<PairDataIndex>> rcvd_elements_of_sampling_atoms; - vector<vector<TripletDataIndex>> recv_periodic_elements_of_sampling_atoms; + std::vector<std::vector<PairDataIndex>> periodic_elements_of_sampling_atoms; + std::vector<std::vector<PairDataIndex>> rcvd_elements_of_sampling_atoms; + std::vector<std::vector<TripletDataIndex>> + recv_periodic_elements_of_sampling_atoms; #ifdef TIMEIT timer neighbourhood_clock; @@ -78,14 +78,14 @@ void neighbourhoods::getRequiredNeighbourhoods( local_sampling_atom_balls.push_back(atom_ball); - elements_of_sampling_atoms.push_back(vector<size_t>{}); + elements_of_sampling_atoms.push_back(std::vector<size_t>{}); - rcvd_elements_of_sampling_atoms.push_back(vector<PairDataIndex>{}); + rcvd_elements_of_sampling_atoms.push_back(std::vector<PairDataIndex>{}); recv_periodic_elements_of_sampling_atoms.push_back( - vector<TripletDataIndex>{}); + std::vector<TripletDataIndex>{}); - periodic_elements_of_sampling_atoms.push_back(vector<PairDataIndex>{}); + periodic_elements_of_sampling_atoms.push_back(std::vector<PairDataIndex>{}); } for (const auto &nodeIndex : _marked_meshExchange_sampling_atoms) { @@ -143,12 +143,12 @@ void neighbourhoods::getRequiredNeighbourhoods( // if(mpi_rank == 3) // { // Simplex simplex; - // array<size_t, DIM+1> indexedSimplex; + // std::array<size_t, DIM+1> indexedSimplex; // size_t cellKey, node_id, cell_id; - // unordered_map<size_t, array<size_t, 4>> tets; - // unordered_map<size_t, point<DIM>> points; - // unordered_map<size_t, int> ranks; + // std::unordered_map<size_t, std::array<size_t, 4>> tets; + // std::unordered_map<size_t, point<DIM>> points; + // std::unordered_map<size_t, int> ranks; // int rank = 4; // node_id = 0; @@ -161,12 +161,12 @@ void neighbourhoods::getRequiredNeighbourhoods( // for(int d=0; d<DIM+1; d++) // { - // points.insert(make_pair(node_id, simplex[d])); + // points.insert(std::make_pair(node_id, simplex[d])); // indexedSimplex[d] = node_id; // node_id++; // } - // tets.insert(make_pair(cell_id, indexedSimplex)); - // ranks.insert(make_pair(cell_id, mpi_rank)); + // tets.insert(std::make_pair(cell_id, indexedSimplex)); + // ranks.insert(std::make_pair(cell_id, mpi_rank)); // cell_id++; // } @@ -175,14 +175,14 @@ void neighbourhoods::getRequiredNeighbourhoods( // if(mpi_rank == 4) // { // Simplex simplex; - // array<size_t, DIM+1> indexedSimplex; + // std::array<size_t, DIM+1> indexedSimplex; // size_t cellKey, node_id, cell_id; // PairDataIndex index_pair; - // unordered_map<size_t, array<size_t, 4>> tets; - // unordered_map<size_t, point<DIM>> points; - // unordered_map<size_t, int> ranks; + // std::unordered_map<size_t, std::array<size_t, 4>> tets; + // std::unordered_map<size_t, point<DIM>> points; + // std::unordered_map<size_t, int> ranks; // int rank = 3; // node_id = 0; @@ -194,18 +194,18 @@ void neighbourhoods::getRequiredNeighbourhoods( // i_el_recv++) // { - // index_pair = make_pair(rank, i_el_recv); + // index_pair = std::make_pair(rank, i_el_recv); // _local_mesh.getPeriodicSimplex(index_pair, simplex); // for(int d=0; d<DIM+1; d++) // { - // points.insert(make_pair(node_id, simplex[d])); + // points.insert(std::make_pair(node_id, simplex[d])); // indexedSimplex[d] = node_id; // node_id++; // } - // tets.insert(make_pair(cell_id, indexedSimplex)); - // ranks.insert(make_pair(cell_id, mpi_rank)); + // tets.insert(std::make_pair(cell_id, indexedSimplex)); + // ranks.insert(std::make_pair(cell_id, mpi_rank)); // cell_id++; // } @@ -221,7 +221,7 @@ void neighbourhoods::getRequiredNeighbourhoods( Simplex offsetSimplex; PairDataIndex index_pair; - vector<size_t> idxs_balls_overlapping; + std::vector<size_t> idxs_balls_overlapping; idxs_balls_overlapping.reserve(local_sampling_atom_balls.size()); // collect local elements on sampling atom balls for (size_t i_el = 0; i_el != _local_mesh.meshCells_.size(); ++i_el) { @@ -254,7 +254,7 @@ void neighbourhoods::getRequiredNeighbourhoods( for (int offsetIndex = 1; offsetIndex < allPeriodicOffsets.size(); offsetIndex++) { - index_pair = make_pair(i_el, offsetIndex); + index_pair = std::make_pair(i_el, offsetIndex); for (int d = 0; d < DIM + 1; d++) offsetSimplex[d] = simplex[d] - allPeriodicOffsets[offsetIndex]; @@ -302,7 +302,7 @@ void neighbourhoods::getRequiredNeighbourhoods( _local_mesh.overlappingMeshData.overlapping_simplices_recv_[i_proc] .size(); i_el_recv++) { - index_pair = make_pair(i_proc, i_el_recv); + index_pair = std::make_pair(i_proc, i_el_recv); _local_mesh.getOverlappingSimplex(index_pair, simplex); @@ -333,14 +333,14 @@ void neighbourhoods::getRequiredNeighbourhoods( _local_mesh.periodicMeshData.overlapping_simplices_recv_[i_proc] .size(); i_el_recv++) { - index_pair = make_pair(i_proc, i_el_recv); + index_pair = std::make_pair(i_proc, i_el_recv); _local_mesh.getPeriodicSimplex(index_pair, simplex); // check for the element's all offsets except for 0 offset for (int offsetIndex = 1; offsetIndex < allPeriodicOffsets.size(); offsetIndex++) { - index_triplet = make_Triplet(i_proc, i_el_recv, offsetIndex); + index_triplet = std::make_Triplet(i_proc, i_el_recv, offsetIndex); for (int d = 0; d < DIM + 1; d++) offsetSimplex[d] = simplex[d] - allPeriodicOffsets[offsetIndex]; @@ -364,14 +364,14 @@ void neighbourhoods::getRequiredNeighbourhoods( } #ifdef FINITE_TEMPERATURE - array<array<double, NIDOF>, DIM + 1> thermal_simplex; + std::array<std::array<double, NIDOF>, DIM + 1> thermal_simplex; #endif #ifdef DISPLAY_NEIGHBOURHOODS bool stored_display_neighbours = false; #endif - array<size_t, DIM + 1> indexedSimplex; + std::array<size_t, DIM + 1> indexedSimplex; point<DIM> neighbour_offset; bool print = false; @@ -393,8 +393,8 @@ void neighbourhoods::getRequiredNeighbourhoods( int recv_offset_idx; bool added; - array<double, DIM + 1> N_j; - array<double, DIM + 1> N_alpha; + std::array<double, DIM + 1> N_j; + std::array<double, DIM + 1> N_alpha; // uniquePointContainer neighbourhood_container; uniquePointList unique_neighbourhood_list; @@ -414,10 +414,10 @@ void neighbourhoods::getRequiredNeighbourhoods( // plainStrain, // constrainedDim); - typename vector<ball>::iterator ballsIterator; - vector<size_t>::const_iterator cellIndexIt; - vector<PairDataIndex>::const_iterator pairIndexIt; - vector<TripletDataIndex>::const_iterator tripletIndexIt; + typename std::vector<ball>::iterator ballsIterator; + std::vector<size_t>::const_iterator cellIndexIt; + std::vector<PairDataIndex>::const_iterator pairIndexIt; + std::vector<TripletDataIndex>::const_iterator tripletIndexIt; int neighbourSiteIndex; @@ -733,7 +733,7 @@ void neighbourhoods::getRequiredNeighbourhoods( recv_offset_idx = tripletIndexIt->third; _local_mesh.getPeriodicSimplex( - make_pair(recv_rank_idx, recv_simplex_idx), simplex); + std::make_pair(recv_rank_idx, recv_simplex_idx), simplex); for (int d = 0; d < DIM + 1; d++) offsetSimplex[d] = @@ -840,7 +840,7 @@ void neighbourhoods::getRequiredNeighbourhoods( if (epsilon < 1.0) // if(mpi_rank == 2 && sampling_atomIndex == 1960) { - array<array<double, DIM>, DIM> rr; + std::array<std::array<double, DIM>, DIM> rr; point<DIM> r_ij; for (int i = 0; i < DIM; i++) { @@ -893,9 +893,9 @@ void neighbourhoods::getRequiredNeighbourhoods( << endl; stored_display_neighbours = true; - unordered_map<size_t, array<size_t, 4>> tets; - unordered_map<size_t, point<DIM>> points; - unordered_map<size_t, int> ranks; + std::unordered_map<size_t, std::array<size_t, 4>> tets; + std::unordered_map<size_t, point<DIM>> points; + std::unordered_map<size_t, int> ranks; size_t node_id = 0; size_t cell_id = 0; @@ -910,12 +910,12 @@ void neighbourhoods::getRequiredNeighbourhoods( simplex = _local_mesh.getSimplex(cellKey); for (int d = 0; d < DIM + 1; d++) { - points.insert(make_pair(node_id, simplex[d])); + points.insert(std::make_pair(node_id, simplex[d])); indexedSimplex[d] = node_id; node_id++; } - tets.insert(make_pair(cell_id, indexedSimplex)); - ranks.insert(make_pair(cell_id, mpi_rank)); + tets.insert(std::make_pair(cell_id, indexedSimplex)); + ranks.insert(std::make_pair(cell_id, mpi_rank)); cell_id++; // } } @@ -937,13 +937,13 @@ void neighbourhoods::getRequiredNeighbourhoods( simplex[d] - allPeriodicOffsets[local_offset_idx]; for (int d = 0; d < DIM + 1; d++) { - points.insert(make_pair(node_id, offsetSimplex[d])); + points.insert(std::make_pair(node_id, offsetSimplex[d])); indexedSimplex[d] = node_id; node_id++; } - tets.insert(make_pair(cell_id, indexedSimplex)); - ranks.insert(make_pair(cell_id, mpi_rank)); + tets.insert(std::make_pair(cell_id, indexedSimplex)); + ranks.insert(std::make_pair(cell_id, mpi_rank)); cell_id++; } @@ -957,13 +957,13 @@ void neighbourhoods::getRequiredNeighbourhoods( _local_mesh.getOverlappingSimplex(*pairIndexIt, simplex); for (int d = 0; d < DIM + 1; d++) { - points.insert(make_pair(node_id, simplex[d])); + points.insert(std::make_pair(node_id, simplex[d])); indexedSimplex[d] = node_id; node_id++; } - tets.insert(make_pair(cell_id, indexedSimplex)); - ranks.insert(make_pair(cell_id, recv_rank_idx)); + tets.insert(std::make_pair(cell_id, indexedSimplex)); + ranks.insert(std::make_pair(cell_id, recv_rank_idx)); cell_id++; } @@ -977,7 +977,7 @@ void neighbourhoods::getRequiredNeighbourhoods( recv_offset_idx = tripletIndexIt->third; _local_mesh.getPeriodicSimplex( - make_pair(recv_rank_idx, recv_simplex_idx), simplex); + std::make_pair(recv_rank_idx, recv_simplex_idx), simplex); for (int d = 0; d < DIM + 1; d++) { offsetSimplex[d] = @@ -985,13 +985,13 @@ void neighbourhoods::getRequiredNeighbourhoods( } for (int d = 0; d < DIM + 1; d++) { - points.insert(make_pair(node_id, offsetSimplex[d])); + points.insert(std::make_pair(node_id, offsetSimplex[d])); indexedSimplex[d] = node_id; node_id++; } - tets.insert(make_pair(cell_id, indexedSimplex)); - ranks.insert(make_pair(cell_id, recv_rank_idx)); + tets.insert(std::make_pair(cell_id, indexedSimplex)); + ranks.insert(std::make_pair(cell_id, recv_rank_idx)); cell_id++; } diff --git a/src/neighbourhoods/neighbourhoods.h b/src/neighbourhoods/neighbourhoods.h index 1169696dc..c6b45d2fe 100644 --- a/src/neighbourhoods/neighbourhoods.h +++ b/src/neighbourhoods/neighbourhoods.h @@ -17,8 +17,6 @@ #include "timer.h" #include "utilities.h" -using namespace geometry; - // bruteForce check of neighbours // store initial neighbours. Then re-run for all neighbours // check the number of neighbours first, @@ -34,10 +32,11 @@ template <typename mesh, typename sampling_atom, typename repatom, // typename simulation, int DIM> void UpdateNeighbourhoodsAllSamplingAtoms( - mesh &_local_mesh, vector<sampling_atom> &_nodal_sampling_atoms, - vector<sampling_atom> &_cb_sampling_atoms, const vector<repatom> &_repatoms, + mesh &_local_mesh, std::vector<sampling_atom> &_nodal_sampling_atoms, + std::vector<sampling_atom> &_cb_sampling_atoms, + const std::vector<repatom> &_repatoms, // const simulation &_simulation, - // vector<size_t> &_interproc_sampling_atoms, + // std::vector<size_t> &_interproc_sampling_atoms, const Box<point<DIM>, DIM> &_domain_bounds); // exchanging and updating nearby mesh elements @@ -46,10 +45,11 @@ void UpdateNeighbourhoodsAllSamplingAtoms( template <typename mesh, typename sampling_atom, typename repatom, typename filewriter, int DIM, int NIDOF> void initializeAllNeighbourhoodsAddForces( - mesh &_local_mesh, vector<sampling_atom> &_nodal_sampling_atoms, - vector<sampling_atom> &_cb_sampling_atoms, vector<repatom> &_local_repatoms, + mesh &_local_mesh, std::vector<sampling_atom> &_nodal_sampling_atoms, + std::vector<sampling_atom> &_cb_sampling_atoms, + std::vector<repatom> &_local_repatoms, const Box<point<DIM>, DIM> &_domain_bounds, - const vector<material<DIM> *> &_materials); + const std::vector<material<DIM> *> &_materials); //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-// //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-// @@ -58,18 +58,21 @@ void initializeAllNeighbourhoodsAddForces( template <typename InputClass, typename mesh, int DIM, int NIDOF> void getRequiredNeighbourhoods(const InputClass &_inputParams, - mesh &_local_mesh, vector<size_t> &, - vector<size_t> &, vector<size_t> &, - vector<size_t> &, const Box<point<DIM>, DIM> &); + mesh &_local_mesh, std::vector<size_t> &, + std::vector<size_t> &, std::vector<size_t> &, + std::vector<size_t> &, + const Box<point<DIM>, DIM> &); template <typename mesh, int DIM, int NIDOF> void updateOverlappingMeshElementsAndNodes( - mesh &_local_mesh, const vector<geom::Ball<double, DIM>> &_inteproc_balls, + mesh &_local_mesh, + const std::vector<geom::Ball<double, DIM>> &_inteproc_balls, const Box<point<DIM>, DIM> &_domain_bounds); template <typename mesh, int DIM, int NIDOF> void updatePeriodicMeshElementsAndNodes( - mesh &_local_mesh, const vector<geom::Ball<double, DIM>> &_periodic_balls, + mesh &_local_mesh, + const std::vector<geom::Ball<double, DIM>> &_periodic_balls, const Box<point<DIM>, DIM> &_domain_bounds); // template<typename mesh, @@ -80,24 +83,24 @@ void updatePeriodicMeshElementsAndNodes( // int DIM, // int NIDOF> // void getRequiredNeighbourhoodsAddForces(mesh &_local_mesh, -// vector<sampling_atom> &_nodal_sampling_atoms, -// vector<sampling_atom> &_cb_sampling_atoms, +// std::vector<sampling_atom> &_nodal_sampling_atoms, +// std::vector<sampling_atom> &_cb_sampling_atoms, // repatomContainer &_local_repatom_container, -// vector<sampling_atomIt> &_triggered_nodal_sampling_atoms, -// vector<sampling_atomIt> &_triggered_cb_sampling_atoms, +// std::vector<sampling_atomIt> &_triggered_nodal_sampling_atoms, +// std::vector<sampling_atomIt> &_triggered_cb_sampling_atoms, // const Box<point<DIM>,DIM> &_domain_bounds, -// const vector<material<DIM> *> &_materials +// const std::vector<material<DIM> *> &_materials // ); template <typename InputClass, typename mesh, typename externalForceApplicator, typename filewriter, int DIM, int NIDOF> void getRequiredNeighbourhoodsAddForces( - const InputClass &_inputParams, mesh &_local_mesh, vector<size_t> &, - vector<size_t> &, vector<size_t> &_triggered_nodal_sampling_atoms, - vector<size_t> &_triggered_cb_sampling_atoms, + const InputClass &_inputParams, mesh &_local_mesh, std::vector<size_t> &, + std::vector<size_t> &, std::vector<size_t> &_triggered_nodal_sampling_atoms, + std::vector<size_t> &_triggered_cb_sampling_atoms, externalForceApplicator *_externalForceApplicator, const Box<point<DIM>, DIM> &_domain_bounds, - const vector<material<DIM> *> &_materials, const bool &); + const std::vector<material<DIM> *> &_materials, const bool &); //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-// #ifdef BRUTE_FORCE_NEIGHBOUR_CHECK @@ -106,26 +109,27 @@ template <typename InputClass, typename mesh, typename externalForceApplicator, void bruteForceNeighbourCheck(const InputClass &_inputParams, mesh &_local_mesh, externalForceApplicator *_externalForceApplicator, const Box<point<DIM>, DIM> &_domain_bounds, - const vector<material<DIM> *> &_materials, + const std::vector<material<DIM> *> &_materials, const bool &); #endif //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-// template <typename mesh, int DIM, int NIDOF> -void AddForcesToRepatoms(mesh &_local_mesh, const vector<material<DIM> *> &); +void AddForcesToRepatoms(mesh &_local_mesh, + const std::vector<material<DIM> *> &); template <typename mesh, int DIM, int NIDOF> -void ComputePotential(mesh &_local_mesh, const vector<material<DIM> *> &); +void ComputePotential(mesh &_local_mesh, const std::vector<material<DIM> *> &); // add phase averaged thermalized forces using // third order quadrature for phase-space integration template <typename mesh, int DIM, int NIDOF> void AddThermalizedForcesToRepatoms_3(mesh &_local_mesh, - const vector<material<DIM> *> &); + const std::vector<material<DIM> *> &); // compute entropy rate from diffusion template <typename mesh, int DIM> void EntropyRateOnsagerKinetics(mesh &_local_mesh, double &_dt, - const vector<material<DIM> *> &); + const std::vector<material<DIM> *> &); // add phase averaged thermalized forces using // fifth order quadrature for phase-space integration @@ -133,9 +137,9 @@ template <typename mesh, typename sampling_atom, typename repatomContainer, int DIM, int NIDOF> void AddThermalizedForcesToRepatoms_5( mesh &_local_mesh, repatomContainer &_local_repatom_container, - const vector<sampling_atom> &_nodal_sampling_atoms, - const vector<sampling_atom> &_cb_sampling_atoms, - const vector<material<DIM> *> &); + const std::vector<sampling_atom> &_nodal_sampling_atoms, + const std::vector<sampling_atom> &_cb_sampling_atoms, + const std::vector<material<DIM> *> &); // update all sampling atom balls // - incident elements -(atomistic and non-atomistic elements) // - neighbour atoms and weights vectors, based on incident elements (only for diff --git a/src/neighbourhoods/neighbourhoods.ipp b/src/neighbourhoods/neighbourhoods.ipp index 66b828566..9e1955f86 100644 --- a/src/neighbourhoods/neighbourhoods.ipp +++ b/src/neighbourhoods/neighbourhoods.ipp @@ -7,19 +7,18 @@ */ #pragma once - -using namespace geometry; +#include "neighbourhoods.h" template <typename mesh, int DIM, int NIDOF> void neighbourhoods::ComputePotential( - mesh &_local_mesh, const vector<material<DIM> *> &_materials) { + mesh &_local_mesh, const std::vector<material<DIM> *> &_materials) { - vector<point<DIM>> cluster; + std::vector<point<DIM>> cluster; double E_s; - vector<int> neighbourIndices; + std::vector<int> neighbourIndices; #ifdef FINITE_TEMPERATURE - vector<array<double, NIDOF>> clusterThermalCoordinates; + std::vector<array<double, NIDOF>> clusterThermalCoordinates; #endif for (size_t atomIndex = 0; @@ -80,12 +79,12 @@ void neighbourhoods::ComputePotential( template <typename mesh, int DIM, int NIDOF> void neighbourhoods::AddForcesToRepatoms( - mesh &_local_mesh, const vector<material<DIM> *> &_materials) { + mesh &_local_mesh, const std::vector<material<DIM> *> &_materials) { typedef lattice::latticeSite<DIM, NIDOF> neighbour_site; - vector<vector<double>> overlapping_nodes_forces_data_send(mpi_size); - vector<vector<double>> overlapping_nodes_forces_data_recv(mpi_size); + std::vector<std::vector<double>> overlapping_nodes_forces_data_send(mpi_size); + std::vector<std::vector<double>> overlapping_nodes_forces_data_recv(mpi_size); for (int i_proc = 0; i_proc < mpi_size; i_proc++) { overlapping_nodes_forces_data_send[i_proc].resize( @@ -98,8 +97,10 @@ void neighbourhoods::AddForcesToRepatoms( 0.0); } - vector<vector<double>> periodic_overlapping_nodes_forces_send(mpi_size); - vector<vector<double>> periodic_overlapping_nodes_forces_recv(mpi_size); + std::vector<std::vector<double>> periodic_overlapping_nodes_forces_send( + mpi_size); + std::vector<std::vector<double>> periodic_overlapping_nodes_forces_recv( + mpi_size); if (periodicSimulationFlag) { for (int i_proc = 0; i_proc < mpi_size; i_proc++) { @@ -122,16 +123,16 @@ void neighbourhoods::AddForcesToRepatoms( #ifdef DEBUG_INTERPROC_NEIGHBOURS _local_mesh.repatoms.dependent_neighbour_bonds_.resize( _local_mesh.repatoms.locations_.size(), - vector<pair<point<DIM>, point<DIM>>>{}); + std::vector<pair<point<DIM>, point<DIM>>>{}); _local_mesh.repatoms.dependent_neighbour_bonds_weights_.resize( - _local_mesh.repatoms.locations_.size(), vector<double>{}); + _local_mesh.repatoms.locations_.size(), std::vector<double>{}); _local_mesh.repatoms.candidate_forces_.resize( - _local_mesh.repatoms.locations_.size(), vector<point<DIM>>{}); + _local_mesh.repatoms.locations_.size(), std::vector<point<DIM>>{}); _local_mesh.repatoms.dependent_neighbour_bonds_multiplicity_.resize( - _local_mesh.repatoms.locations_.size(), vector<int>{}); + _local_mesh.repatoms.locations_.size(), std::vector<int>{}); #endif point<DIM> f_ij; @@ -149,11 +150,14 @@ void neighbourhoods::AddForcesToRepatoms( typedef pair<point<DIM>, point<DIM>> bond; - vector<vector<vector<bond>>> interproc_nodes_bonds(mpi_size); - vector<vector<int>> noof_bonds_send(mpi_size); - vector<vector<vector<double>>> interproc_nodes_bonds_weights(mpi_size); - vector<vector<vector<int>>> bonds_sampling_atoms_connected_flag(mpi_size); - vector<vector<vector<point<DIM>>>> interproc_nodes_bonds_forces(mpi_size); + std::vector<std::vector<std::vector<bond>>> interproc_nodes_bonds(mpi_size); + std::vector<std::vector<int>> noof_bonds_send(mpi_size); + std::vector<std::vector<std::vector<double>>> interproc_nodes_bonds_weights( + mpi_size); + std::vector<std::vector<std::vector<int>>> + bonds_sampling_atoms_connected_flag(mpi_size); + std::vector<std::vector<std::vector<point<DIM>>>> + interproc_nodes_bonds_forces(mpi_size); for (int i_proc = 0; i_proc < mpi_size; i_proc++) { noof_bonds_send[i_proc].resize( @@ -175,9 +179,9 @@ void neighbourhoods::AddForcesToRepatoms( //==================================================== // #endif - vector<point<DIM>> clusterForces; - vector<point<DIM>> cluster; - vector<int> neighbourIndices; + std::vector<point<DIM>> clusterForces; + std::vector<point<DIM>> cluster; + std::vector<int> neighbourIndices; int noofDependencies, neighbourIndex; @@ -445,13 +449,17 @@ void neighbourhoods::AddForcesToRepatoms( { size_t total_noof_communication_bonds; - vector<vector<double>> interproc_nodes_bonds_data(mpi_size); - vector<vector<int>> noof_bonds_recv(mpi_size); - vector<vector<double>> bonds_recv(mpi_size); - vector<vector<int>> bonds_sampling_atoms_connected_flag_recv(mpi_size); - vector<vector<int>> bonds_sampling_atoms_connected_flag_send(mpi_size); - vector<vector<double>> interproc_nodes_bonds_force_send(mpi_size); - vector<vector<double>> interproc_nodes_bonds_force_recv(mpi_size); + std::vector<std::vector<double>> interproc_nodes_bonds_data(mpi_size); + std::vector<std::vector<int>> noof_bonds_recv(mpi_size); + std::vector<std::vector<double>> bonds_recv(mpi_size); + std::vector<std::vector<int>> bonds_sampling_atoms_connected_flag_recv( + mpi_size); + std::vector<std::vector<int>> bonds_sampling_atoms_connected_flag_send( + mpi_size); + std::vector<std::vector<double>> interproc_nodes_bonds_force_send( + mpi_size); + std::vector<std::vector<double>> interproc_nodes_bonds_force_recv( + mpi_size); for (int i_proc = 0; i_proc < mpi_size; i_proc++) { total_noof_communication_bonds = accumulate( @@ -591,23 +599,23 @@ void neighbourhoods::AddForcesToRepatoms( } } - vector<vector<double>> connected_nodes_bonds_data_send( + std::vector<std::vector<double>> connected_nodes_bonds_data_send( _local_mesh.connected_node_procs_.size()); - vector<vector<double>> connected_nodes_bonds_data_recv( + std::vector<std::vector<double>> connected_nodes_bonds_data_recv( _local_mesh.connected_node_procs_.size()); - vector<vector<int>> connected_nodes_bonds_multiplicity_send( + std::vector<std::vector<int>> connected_nodes_bonds_multiplicity_send( _local_mesh.connected_node_procs_.size()); - vector<vector<int>> connected_nodes_bonds_multiplicity_recv( + std::vector<std::vector<int>> connected_nodes_bonds_multiplicity_recv( _local_mesh.connected_node_procs_.size()); - vector<vector<double>> connected_nodes_bonds_force_send( + std::vector<std::vector<double>> connected_nodes_bonds_force_send( _local_mesh.connected_node_procs_.size()); - vector<vector<double>> connected_nodes_bonds_force_recv( + std::vector<std::vector<double>> connected_nodes_bonds_force_recv( _local_mesh.connected_node_procs_.size()); // now exchange bonds for directly connected nodes - vector<vector<int>> noof_connected_bonds_send( + std::vector<std::vector<int>> noof_connected_bonds_send( _local_mesh.connected_node_procs_.size()); - vector<vector<int>> noof_connected_bonds_recv( + std::vector<std::vector<int>> noof_connected_bonds_recv( _local_mesh.connected_node_procs_.size()); for (int i_proc = 0; i_proc < _local_mesh.connected_node_procs_.size(); @@ -829,10 +837,10 @@ void neighbourhoods::AddForcesToRepatoms( // no need to do this. Periodic nodes are also marked as ghosts // use petsc vector for adding force assembly - // vector<vector<double>> connected_nodes_forces_data_send( + // std::vector<std::vector<double>> connected_nodes_forces_data_send( // _local_mesh.connected_node_procs_.size()); - // vector<vector<double>> connected_nodes_forces_data_recv( + // std::vector<std::vector<double>> connected_nodes_forces_data_recv( // _local_mesh.connected_node_procs_.size()); // for(int i_proc=0; i_proc<_local_mesh.connected_node_procs_.size(); @@ -927,10 +935,11 @@ void neighbourhoods::AddForcesToRepatoms( template <typename mesh, typename sampling_atom, typename repatom, typename filewriter, int DIM, int NIDOF> void neighbourhoods::initializeAllNeighbourhoodsAddForces( - mesh &_local_mesh, vector<sampling_atom> &_nodal_sampling_atoms, - vector<sampling_atom> &_cb_sampling_atoms, vector<repatom> &_local_repatoms, + mesh &_local_mesh, std::vector<sampling_atom> &_nodal_sampling_atoms, + std::vector<sampling_atom> &_cb_sampling_atoms, + std::vector<repatom> &_local_repatoms, const Box<point<DIM>, DIM> &_domain_bounds, - const vector<material<DIM> *> &_materials) { + const std::vector<material<DIM> *> &_materials) { neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms< mesh, sampling_atom, repatom, filewriter, DIM>( @@ -949,13 +958,13 @@ template <typename InputClass, typename mesh, typename externalForceApplicator, typename filewriter, int DIM, int NIDOF> void neighbourhoods::getRequiredNeighbourhoodsAddForces( const InputClass &_inputParams, mesh &_local_mesh, - vector<size_t> &_triggered_meshExchange_sampling_atoms, - vector<size_t> &_triggered_periodicMeshExchange_sampling_atoms, - vector<size_t> &_triggered_nodal_sampling_atoms, - vector<size_t> &_triggered_cb_sampling_atoms, + std::vector<size_t> &_triggered_meshExchange_sampling_atoms, + std::vector<size_t> &_triggered_periodicMeshExchange_sampling_atoms, + std::vector<size_t> &_triggered_nodal_sampling_atoms, + std::vector<size_t> &_triggered_cb_sampling_atoms, externalForceApplicator *_externalForceApplicator, const Box<point<DIM>, DIM> &_domain_bounds, - const vector<material<DIM> *> &_materials, + const std::vector<material<DIM> *> &_materials, const bool &_applyExternalForce) { // triggered sampling atoms have no neighbours. Update those diff --git a/src/neighbourhoods/neighbourhoods_global.h b/src/neighbourhoods/neighbourhoods_global.h index 92bad7a47..d199d2da2 100644 --- a/src/neighbourhoods/neighbourhoods_global.h +++ b/src/neighbourhoods/neighbourhoods_global.h @@ -14,8 +14,6 @@ #include "mpiutilities.h" #include "utilities.h" -using namespace std; - namespace neighbourhoods { template <typename point_d> class InterProcNeighbourQuery { @@ -28,20 +26,20 @@ public: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { - ar & this->CenterInterProcBoundaryFlag; - ar & this->SamplingAtomLocation; - ar & this->SeedElementID; - ar & this->radius; + ar &this->CenterInterProcBoundaryFlag; + ar &this->SamplingAtomLocation; + ar &this->SeedElementID; + ar &this->radius; }; }; class InterProcNeighbourData { public: - vector<vector<double>> NeighbourPoints; - vector<double> Center; + std::vector<std::vector<double>> NeighbourPoints; + std::vector<double> Center; bool CenterInterProcBoundaryFlag; - vector<vector<int>> DependentRepAtoms; - vector<vector<double>> ShapeFunctionsRepAtomsAtNeighbours; + std::vector<std::vector<int>> DependentRepAtoms; + std::vector<std::vector<double>> ShapeFunctionsRepAtomsAtNeighbours; InterProcNeighbourData() { this->NeighbourPoints.resize(0); @@ -53,19 +51,19 @@ public: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { - ar & this->Center; - ar & this->CenterInterProcBoundaryFlag; - ar & this->DependentRepAtoms; - ar & this->ShapeFunctionsRepAtomsAtNeighbours; + ar &this->Center; + ar &this->CenterInterProcBoundaryFlag; + ar &this->DependentRepAtoms; + ar &this->ShapeFunctionsRepAtomsAtNeighbours; }; }; template <typename point_d> class InterProcNeighbourPoints { public: int number_of_atoms_; - vector<int> number_of_neighbour_points_; - vector<vector<point_d>> neighbour_points_; - vector<vector<double>> weights_from_neighbours_; + std::vector<int> number_of_neighbour_points_; + std::vector<std::vector<point_d>> neighbour_points_; + std::vector<std::vector<double>> weights_from_neighbours_; InterProcNeighbourPoints() { this->number_of_atoms_ = 0; @@ -77,9 +75,9 @@ public: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { - ar & this->number_of_atoms_; - ar & this->number_of_neighbour_points_; - ar & this->weights_from_neighbours_; + ar &this->number_of_atoms_; + ar &this->number_of_neighbour_points_; + ar &this->weights_from_neighbours_; // ar & this->neighbour_points_; }; }; @@ -94,42 +92,43 @@ public: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { - ar & this->active_; - ar & this->atom_; - ar & this->own_rank_; - ar & this->connected_rank_; + ar &this->active_; + ar &this->atom_; + ar &this->own_rank_; + ar &this->connected_rank_; }; }; template <typename point_d, typename sampling_atom, int DIM> -void CalcPairPotentialAndForce(const vector<material<DIM> *> &, - vector<sampling_atom> &); +void CalcPairPotentialAndForce(const std::vector<material<DIM> *> &, + std::vector<sampling_atom> &); template <typename point_d, typename sampling_atom, int DIM> -void CalcEmbeddingPotentialAndForce(const vector<material<DIM> *> &, - vector<sampling_atom> &); +void CalcEmbeddingPotentialAndForce(const std::vector<material<DIM> *> &, + std::vector<sampling_atom> &); template <typename Vector_d, typename point_d, typename sampling_atom, int DIM> -void CalcForceVectorsEachNeighbour(vector<sampling_atom> &); +void CalcForceVectorsEachNeighbour(std::vector<sampling_atom> &); template <typename Vector_d, typename sampling_atom, typename repatom, int DIM> -void AddForceToRepAtoms(vector<sampling_atom> &, vector<repatom> &); +void AddForceToRepAtoms(std::vector<sampling_atom> &, std::vector<repatom> &); template <typename point_d, typename Vector_d, typename mesh_d, typename sampling_atom, typename repatom, int DIM> -void AddForceToInterProcRepAtoms(vector<sampling_atom> &, vector<repatom> &, - const mesh_d &, - const vector<vector<InterProcNeighbourData>> &, - const vector<vector<int>> &, - const vector<vector<int>> &, - const vector<vector<int>> &, - const vector<vector<int>> &); +void AddForceToInterProcRepAtoms( + std::vector<sampling_atom> &, std::vector<repatom> &, const mesh_d &, + const std::vector<std::vector<InterProcNeighbourData>> &, + const std::vector<std::vector<int>> &, + const std::vector<std::vector<int>> &, + const std::vector<std::vector<int>> &, + const std::vector<std::vector<int>> &); template <typename point_d, typename Vector_d, typename ball_d, typename mesh_d, typename sampling_atom, typename repatom, typename vtkWriter, int DIM> -void ArrangeNeighboursAndAddForces(vector<sampling_atom> &, vector<repatom> &, - mesh_d &, const mesh_d &, - const vector<material<DIM> *> &); +void ArrangeNeighboursAndAddForces(std::vector<sampling_atom> &, + std::vector<repatom> &, mesh_d &, + const mesh_d &, + const std::vector<material<DIM> *> &); template <typename mesh_d, int DIM> void ResetAllLatticeSites(mesh_d &_mesh) { for (int i_el = 0; i_el < _mesh.NoofElements; i_el++) { @@ -138,29 +137,30 @@ template <typename mesh_d, int DIM> void ResetAllLatticeSites(mesh_d &_mesh) { } template <typename atom, int DIM> -void ResetAllNeighbourDependecies(vector<atom> &_atoms) { +void ResetAllNeighbourDependecies(std::vector<atom> &_atoms) { for (int i_atom = 0; i_atom < _atoms.size(); i_atom++) { _atoms[i_atom].ResetNeighbourVectors(); _atoms[i_atom].ResetDependentNeighbours(); } } -template <typename atom, int DIM> void ResetAllRepAtoms(vector<atom> &_atoms) { +template <typename atom, int DIM> +void ResetAllRepAtoms(std::vector<atom> &_atoms) { for (atom &repatom : _atoms) { repatom.ResetDependentBondsAndForces(); } } template <typename point_d, typename mesh_d, int DIM> void AddElementLatticeSites(mesh_d &_mesh, - const vector<material<DIM> *> &_materials) { + const std::vector<material<DIM> *> &_materials) { double longest_edge_length, r_cut; for (int i_el = 0; i_el < _mesh.NoofElements; i_el++) { - array<point_d, DIM + 1> simplex; + std::array<point_d, DIM + 1> simplex; for (int iv = 0; iv < DIM + 1; iv++) { simplex[iv] = _mesh.MeshNodes[_mesh.MeshElements[i_el].VerticesOfElement[iv]]; } - array<unsigned int, 2> LongestEdge = + std::array<unsigned int, 2> LongestEdge = FindLongestEdgeOfSimplex<point_d>(simplex, longest_edge_length); r_cut = _materials[_mesh.MeshElements[i_el].MaterialIndex] @@ -185,24 +185,24 @@ template <typename point_d, typename mesh_d, typename ball_d, int DIM> inline void AddUniqueNeighbourPointsAndRepAtomsOfElement( const mesh_d &_mesh, const ball_d &_neighbour_ball, const int &_element_id, const point_d &_atom_location, - vector<double> &_atom_weight_of_sampling_atom, - vector<point_d> &_atom_neighbour_points, - vector<vector<int>> &_atom_dependent_repatoms, - vector<vector<double>> &_atom_shapefunctions_neighbours) { + std::vector<double> &_atom_weight_of_sampling_atom, + std::vector<point_d> &_atom_neighbour_points, + std::vector<std::vector<int>> &_atom_dependent_repatoms, + std::vector<std::vector<double>> &_atom_shapefunctions_neighbours) { bool added_neighbour = false; bool added_repatom = false; bool added_neighbourhood_center = false; - vector<int> vertices_idx(DIM + 1); + std::vector<int> vertices_idx(DIM + 1); - vector<int> vertices_idx_tobe_added; - vector<double> N_ij_tobe_added; + std::vector<int> vertices_idx_tobe_added; + std::vector<double> N_ij_tobe_added; int idx_present_repatom; - array<point_d, DIM + 1> simplex; + std::array<point_d, DIM + 1> simplex; - vector<double> N_ij(DIM + 1); - vector<double> N_alpha(DIM + 1); + std::vector<double> N_ij(DIM + 1); + std::vector<double> N_alpha(DIM + 1); for (int d = 0; d < DIM + 1; d++) { vertices_idx[d] = _mesh.MeshElements[_element_id].VerticesOfElement[d]; @@ -309,7 +309,7 @@ void GraphDirectLocalSearch( const mesh_d &_mesh, const mesh_d &_global_mesh, const int &_caller_rank, const double &_rcut, const int &_nodeid, const ball_d &_neighbour_ball, const int &_seed, sampling_atom &_atom, - vector<vector<SamplingAtomRelayQuery<sampling_atom>>> + std::vector<std::vector<SamplingAtomRelayQuery<sampling_atom>>> &_relay_queries_send) { int global_seed = _mesh.LocalToGlobalElements[_seed]; int local_neighbour_id; @@ -322,11 +322,11 @@ void GraphDirectLocalSearch( // _atom.ConnectedProcs.resize(0); // _atom.IsNearProcBoundary = false; - vector<bool> visited_elements(_global_mesh.NoofElements, false); - array<point_d, DIM + 1> simplex; + std::vector<bool> visited_elements(_global_mesh.NoofElements, false); + std::array<point_d, DIM + 1> simplex; - list<int> neighbour_candidates; - list<array<point_d, DIM + 1>> neighbour_candidates_with_points; + std::list<int> neighbour_candidates; + std::list<std::array<point_d, DIM + 1>> neighbour_candidates_with_points; neighbour_candidates.push_back(global_seed); for (int iv = 0; iv < DIM + 1; iv++) { @@ -338,7 +338,7 @@ void GraphDirectLocalSearch( visited_elements[global_seed] = true; int neighbour, adjacent; - array<point_d, DIM + 1> neighbour_simplex; + std::array<point_d, DIM + 1> neighbour_simplex; bool store_connected_proc_query = true; @@ -374,7 +374,7 @@ void GraphDirectLocalSearch( // if(idx == _atom.ConnectedProcs.size()) if (added) { // _atom.ConnectedProcs.insert(rank_of_element); - // _atom.ConnectedElementIds.push_back(vector<int>{neighbour}); + // _atom.ConnectedElementIds.push_back(std::vector<int>{neighbour}); _atom.ConnectedSeedElementIds.push_back(neighbour); } else { // _atom.ConnectedSeedElementIds[idx] = neighbour; @@ -409,19 +409,19 @@ void GraphDirectLocalSearch( template <typename point_d, typename mesh_d, typename ball_d, int DIM> void GraphDirectLocalSearch_ReceivedQuery( const mesh_d &_mesh, const point_d &_atom, const ball_d &_neighbour_ball, - const int &_seed, vector<double> &_atom_weight_of_sampling_atom, - vector<point_d> &_NeighbourPoints, - vector<vector<int>> &_atom_dependent_repatoms, - vector<vector<double>> &_atom_shapefunctions_neighbours) { + const int &_seed, std::vector<double> &_atom_weight_of_sampling_atom, + std::vector<point_d> &_NeighbourPoints, + std::vector<std::vector<int>> &_atom_dependent_repatoms, + std::vector<std::vector<double>> &_atom_shapefunctions_neighbours) { _NeighbourPoints.resize(0); int local_seed = _mesh.GlobalToLocalElements[_seed]; - vector<bool> visited_elements(_mesh.NoofElements, false); - array<point_d, DIM + 1> simplex; + std::vector<bool> visited_elements(_mesh.NoofElements, false); + std::array<point_d, DIM + 1> simplex; - list<int> neighbour_candidates; + std::list<int> neighbour_candidates; neighbour_candidates.push_back(local_seed); visited_elements[local_seed] = true; @@ -478,14 +478,16 @@ void GraphDirectLocalSearch_ReceivedQuery( template <typename point_d, typename ball_d, typename mesh_d, typename sampling_atom, typename vtkWriter, int DIM> void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( - mesh_d &_mesh, vector<sampling_atom> &_atoms, - vector<vector<InterProcNeighbourData>> + mesh_d &_mesh, std::vector<sampling_atom> &_atoms, + std::vector<std::vector<InterProcNeighbourData>> &_connected_repatoms_other_proc_sampling_atoms, - vector<vector<int>> &_number_of_neighbours_other_proc_sampling_atoms, - vector<vector<int>> &_number_of_neighbours_connected_sampling_atoms, - vector<vector<int>> &_unique_neighbours_other_proc_sampling_atoms, - vector<vector<int>> &_unique_neighbours_connected_sampling_atoms, - vector<vector<SamplingAtomRelayQuery<sampling_atom>>> + std::vector<std::vector<int>> + &_number_of_neighbours_other_proc_sampling_atoms, + std::vector<std::vector<int>> + &_number_of_neighbours_connected_sampling_atoms, + std::vector<std::vector<int>> &_unique_neighbours_other_proc_sampling_atoms, + std::vector<std::vector<int>> &_unique_neighbours_connected_sampling_atoms, + std::vector<std::vector<SamplingAtomRelayQuery<sampling_atom>>> &_relay_queries_send) { int rank_of_element; @@ -517,7 +519,7 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( // _mesh.ConnectedProcs_SamplingAtoms.insert(connected_proc); // _mesh.ConnectedSamplingAtoms.push_back(set<int>{sampling_atom_ctr}); _mesh.ConnectedSamplingAtoms.push_back( - vector<int>{sampling_atom_ctr}); + std::vector<int>{sampling_atom_ctr}); } else { // _mesh.ConnectedSamplingAtoms[idx].insert(sampling_atom_ctr); int idx_temp; @@ -530,7 +532,7 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( } // Organize the processors to which queries will be sent - vector<int> IfSendingQueryToRank(mpi_size, 0); + std::vector<int> IfSendingQueryToRank(mpi_size, 0); for (int proc = 0; proc < mpi_size; proc++) { // int idx = distance(_mesh.ConnectedProcs_SamplingAtoms.begin(), @@ -546,7 +548,7 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( } // Organize the processors from which queries will be received - vector<int> IfReceivingQueryFromRank(mpi_size, 0); + std::vector<int> IfReceivingQueryFromRank(mpi_size, 0); mpi_utilities::MPIExchangeConnectedProcs(IfSendingQueryToRank, IfReceivingQueryFromRank, mpi_size); @@ -562,9 +564,9 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( // Organize the number of sampling atoms sending queries // And number of sampling atoms of other procs // from which to receive the queries - vector<int> NumberOfSamplingAtomsToBeSent( + std::vector<int> NumberOfSamplingAtomsToBeSent( _mesh.SendingProcs_SamplingAtoms.size()); - vector<int> NumberOfSamplingAtomsToBeReceived( + std::vector<int> NumberOfSamplingAtomsToBeReceived( _mesh.ReceivingProcs_SamplingAtoms.size()); for (int i_proc = 0; i_proc < _mesh.SendingProcs_SamplingAtoms.size(); @@ -589,10 +591,10 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( // is kept using simple vectors // Arrange interprocquery for neighbours in other processors - vector<vector<InterProcNeighbourQuery<point_d>>> QueryToBeSent( + std::vector<std::vector<InterProcNeighbourQuery<point_d>>> QueryToBeSent( _mesh.SendingProcs_SamplingAtoms.size()); - vector<vector<InterProcNeighbourQuery<point_d>>> QueryToBeReceived( + std::vector<std::vector<InterProcNeighbourQuery<point_d>>> QueryToBeReceived( _mesh.ReceivingProcs_SamplingAtoms.size()); for (int i_proc = 0; i_proc < _mesh.SendingProcs_SamplingAtoms.size(); @@ -633,39 +635,39 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( _mesh.SendingProcs_SamplingAtoms, _mesh.ReceivingProcs_SamplingAtoms); - // vector<vector<int>> + // std::vector<std::vector<int>> // NumberOfNeighbourPointsOfReceivedQueries(_mesh.ReceivingProcs_SamplingAtoms.size()); _number_of_neighbours_other_proc_sampling_atoms.resize( _mesh.ReceivingProcs_SamplingAtoms.size()); - // vector<vector<int>> + // std::vector<std::vector<int>> // NumberOfNeighbourPointsOfSentQueries(_mesh.SendingProcs_SamplingAtoms.size()); _number_of_neighbours_connected_sampling_atoms.resize( _mesh.SendingProcs_SamplingAtoms.size()); - vector<vector<double>> NeighbourPointsAndWeightsFromReceivedQueries( + std::vector<std::vector<double>> NeighbourPointsAndWeightsFromReceivedQueries( _mesh.ReceivingProcs_SamplingAtoms.size()); - vector<vector<double>> NeighbourPointsAndWeightsFromSentQueries( + std::vector<std::vector<double>> NeighbourPointsAndWeightsFromSentQueries( _mesh.SendingProcs_SamplingAtoms.size()); _connected_repatoms_other_proc_sampling_atoms.resize( _mesh.ReceivingProcs_SamplingAtoms.size()); - // vector<vector<int>> + // std::vector<std::vector<int>> // UniqueNeighboursAddedFromSentSamplingAtoms(_mesh.SendingProcs_SamplingAtoms.size()); _unique_neighbours_connected_sampling_atoms.resize( _mesh.SendingProcs_SamplingAtoms.size()); - // vector<vector<int>> + // std::vector<std::vector<int>> // UniqueNeighboursAddedFromReceivedSamplingAtoms(_mesh.ReceivingProcs_SamplingAtoms.size()); _unique_neighbours_other_proc_sampling_atoms.resize( _mesh.ReceivingProcs_SamplingAtoms.size()); point_d query_atom; - vector<double> coordinates(DIM); + std::vector<double> coordinates(DIM); ball_d neighbour_ball; int seed_element_global_id; - vector<point_d> neighbour_points; - vector<double> weights_from_neighbours; + std::vector<point_d> neighbour_points; + std::vector<double> weights_from_neighbours; for (int i_proc = 0; i_proc < _mesh.ReceivingProcs_SamplingAtoms.size(); i_proc++) { @@ -714,8 +716,8 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( // ********************************************************************************* // // _connected_repatoms_other_proc_sampling_atoms[i_proc][i_atom] - .NeighbourPoints.push_back( - vector<double>{neighbour_points[i][0], neighbour_points[i][1]}); + .NeighbourPoints.push_back(std::vector<double>{ + neighbour_points[i][0], neighbour_points[i][1]}); // ********************************************************************************* // // } @@ -804,9 +806,9 @@ void AddNeighboursAndDependentRepAtomsOfInterProcSamplingAtoms( _mesh.SendingProcs_SamplingAtoms, _mesh.ReceivingProcs_SamplingAtoms); // /************************ All global Elements IDS query**************/ - // vector<vector<int>> + // std::vector<std::vector<int>> // NeighbourElementQueryToBeSent(_mesh.SendingProcs_SamplingAtoms.size()); - // vector<vector<int>> + // std::vector<std::vector<int>> // NeighbourElementQueryToBeReceived(_mesh.ReceivingProcs_SamplingAtoms.size()); // for(int i_proc=0; i_proc<_mesh.SendingProcs_SamplingAtoms.size(); i_proc++) @@ -856,17 +858,18 @@ template <typename point_d, typename mesh_d, typename ball_d, typename sampling_atom, int DIM> void AssembleNeighbourhoodsLocalToProc( const mesh_d &_mesh, const mesh_d &_global_mesh, - const vector<material<DIM> *> &_materials, vector<sampling_atom> &_atoms, - vector<vector<SamplingAtomRelayQuery<sampling_atom>>> + const std::vector<material<DIM> *> &_materials, + std::vector<sampling_atom> &_atoms, + std::vector<std::vector<SamplingAtomRelayQuery<sampling_atom>>> &_relay_queries_send) { int repatom_of_samplingatom; int seed_element; double r_cut; ball_d neighbour_ball; - array<point_d, DIM + 1> simplex; - vector<double> N_ij(DIM + 1); - vector<double> N_alpha(DIM + 1); + std::array<point_d, DIM + 1> simplex; + std::vector<double> N_ij(DIM + 1); + std::vector<double> N_alpha(DIM + 1); int sampling_atom_ctr = 0; @@ -894,8 +897,9 @@ void AssembleNeighbourhoodsLocalToProc( } if (seed_element == FORBIDDEN_IDX) { - cout << " No local incident element found for this sampling atom ..." - << endl; + std::cout + << " No local incident element found for this sampling atom ..." + << std::endl; exit(0); } @@ -956,4 +960,4 @@ void AssembleNeighbourhoodsLocalToProc( #include "CalculatePotentialsAndForces.ipp" -#include "AddForcesToAllRepatoms.ipp" \ No newline at end of file +#include "AddForcesToAllRepatoms.ipp" diff --git a/src/neighbourhoods/overlappingMeshExchange.ipp b/src/neighbourhoods/overlappingMeshExchange.ipp index 59f9f1527..1c6df72ec 100644 --- a/src/neighbourhoods/overlappingMeshExchange.ipp +++ b/src/neighbourhoods/overlappingMeshExchange.ipp @@ -10,12 +10,10 @@ #include "neighbourhoods.h" #include <uniquePointContainer.h> -using namespace geometry; - template <typename mesh, int DIM, int NIDOF> void neighbourhoods::updateOverlappingMeshElementsAndNodes( mesh &_local_mesh, - const vector<geom::Ball<double, DIM>> &_interproc_atom_balls, + const std::vector<geom::Ball<double, DIM>> &_interproc_atom_balls, const Box<point<DIM>, DIM> &_domain_bounds) { // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// // -gather information about refinements. If refinements happened, @@ -28,14 +26,14 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( // duplicate elements. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// typedef point<DIM> Point; - typedef array<point<DIM>, DIM + 1> Simplex; + typedef std::array<point<DIM>, DIM + 1> Simplex; typedef Eigen::Matrix<double, DIM, DIM> Matrix; typedef geom::Ball<double, DIM> ball; typedef uniquePointContainer<Point, DIM> UniqueContainer; - typedef pair<int, size_t> _pairKey_; + typedef std::pair<int, size_t> _pairKey_; - vector<int> noof_interproc_balls_data(mpi_size, 0); - vector<double> balls_data_to_bcast; + std::vector<int> noof_interproc_balls_data(mpi_size, 0); + std::vector<double> balls_data_to_bcast; int noof_interproc_sampling_atoms = _interproc_atom_balls.size(); @@ -56,7 +54,7 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( // use vanilla MPI (use all_gatherv with open-mpi) // first compute the displacements from _N - vector<int> displacements(mpi_size, 0); + std::vector<int> displacements(mpi_size, 0); for (int i_rank = 1; i_rank != mpi_size; ++i_rank) { displacements[i_rank] = displacements[i_rank - 1] + noof_interproc_balls_data[i_rank - 1]; @@ -69,24 +67,24 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( // | | // <-displacement[r]--> - vector<double> balls_data_all_proc(displacements[mpi_size - 1] + - noof_interproc_balls_data[mpi_size - 1]); + std::vector<double> balls_data_all_proc( + displacements[mpi_size - 1] + noof_interproc_balls_data[mpi_size - 1]); // all gather will not work in case // billions of sampling atoms are sending data mpi_utilities::ALLGATHERV<double>(balls_data_to_bcast, balls_data_all_proc, noof_interproc_balls_data, displacements); - vector<int> ball_procs_delimiters(mpi_size + 1, 0); + std::vector<int> ball_procs_delimiters(mpi_size + 1, 0); for (int i = 0; i < mpi_size; i++) { ball_procs_delimiters[i + 1] = displacements[i] / (DIM + 1) + noof_interproc_balls_data[i] / (DIM + 1); } - vector<geom::Ball<double, DIM>> balls_all_proc; + std::vector<geom::Ball<double, DIM>> balls_all_proc; balls_all_proc.reserve(balls_data_all_proc.size() / (DIM + 1)); - vector<vector<int>> ranks_of_unique_balls; + std::vector<std::vector<int>> ranks_of_unique_balls; ranks_of_unique_balls.reserve(balls_data_all_proc.size() / (DIM + 1)); size_t noof_balls_all_proc = balls_data_all_proc.size() / (DIM + 1); @@ -106,7 +104,7 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( int unique_ball_idx, ball_rank; for (size_t ball_ctr = 0; ball_ctr < noof_balls_all_proc; ball_ctr++) { - const vector<int>::const_iterator it = upper_bound( + const std::vector<int>::const_iterator it = upper_bound( ball_procs_delimiters.cbegin(), ball_procs_delimiters.cend(), ball_ctr); ball_rank = distance(ball_procs_delimiters.cbegin(), it) - 1; @@ -122,7 +120,7 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( if (added) { balls_all_proc.push_back(interproc_ball); - ranks_of_unique_balls.push_back(vector<int>{ball_rank}); + ranks_of_unique_balls.push_back(std::vector<int>{ball_rank}); } else { // it was previously added ranks_of_unique_balls[unique_ball_idx].push_back(ball_rank); @@ -148,11 +146,11 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( interproc_ball_simplex_query(balls_all_proc.begin(), balls_all_proc.end()); - vector<int> idxs_balls_overlapping; + std::vector<int> idxs_balls_overlapping; idxs_balls_overlapping.reserve(int(balls_all_proc.size() / mpi_size)); - vector<vector<size_t>> added_simplex_idxs_for_sending(mpi_size); - vector<vector<size_t>> added_node_idxs_for_sending(mpi_size); + std::vector<std::vector<size_t>> added_simplex_idxs_for_sending(mpi_size); + std::vector<std::vector<size_t>> added_node_idxs_for_sending(mpi_size); for (int i_proc = 0; i_proc < mpi_size; i_proc++) { added_simplex_idxs_for_sending[i_proc].reserve( @@ -198,13 +196,13 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( // one by one and receive, with traditional non-blocking MPI_Isend // data to be sent is nodes (coordinates), lattice vectors, // atomistic flags. - vector<vector<double>> all_send_double_data(mpi_size); - vector<vector<int>> all_send_int_data(mpi_size); + std::vector<std::vector<double>> all_send_double_data(mpi_size); + std::vector<std::vector<int>> all_send_int_data(mpi_size); - vector<int> noof_simplices_send(mpi_size, 0); - vector<int> noof_nodes_send(mpi_size, 0); + std::vector<int> noof_simplices_send(mpi_size, 0); + std::vector<int> noof_nodes_send(mpi_size, 0); - vector<double> meshnodes_send; + std::vector<double> meshnodes_send; meshnodes_send.reserve(_local_mesh.meshNodes_.size() * DIM #ifdef FINITE_TEMPERATURE @@ -214,10 +212,10 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( // we have to send only 2 quantities (omega and sigma) - // // vector<bool> added_nodes(_local_mesh.meshNodes_.size(), false); + // // std::vector<bool> added_nodes(_local_mesh.meshNodes_.size(), false); // unordered_set<size_t> added_nodes; - // vector<int> added_nodes_local_indices( + // std::vector<int> added_nodes_local_indices( // _local_mesh.meshNodes_.size(), numeric_limits<int>::max()); size_t cellKey, nodeKey, nodeIndex, sentIndex; @@ -267,8 +265,8 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( // added_nodes.insert(nodeKey); _local_mesh.overlappingMeshData .overlap_nodes_sent_idx_recv_side_[i_proc] - .insert(make_pair(static_cast<int>(nodeKey), - static_cast<int>(sentIndex))); + .insert(std::make_pair(static_cast<int>(nodeKey), + static_cast<int>(sentIndex))); added_node_idxs_for_sending[i_proc].push_back(nodeIndex); @@ -351,9 +349,9 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( unique_balls.clear(); - vector<double>().swap(meshnodes_send); - vector<int> noof_simplices_recv(mpi_size, 0); - vector<int> noof_nodes_recv(mpi_size, 0); + std::vector<double>().swap(meshnodes_send); + std::vector<int> noof_simplices_recv(mpi_size, 0); + std::vector<int> noof_nodes_recv(mpi_size, 0); mpi_utilities::MPIExchangeBuffers_NonBlocking<int>( noof_simplices_send, noof_simplices_recv, mpi_size); @@ -370,8 +368,8 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( } #endif - vector<vector<double>> all_recv_double_data(mpi_size); - vector<vector<int>> all_recv_int_data(mpi_size); + std::vector<std::vector<double>> all_recv_double_data(mpi_size); + std::vector<std::vector<int>> all_recv_int_data(mpi_size); for (int i = 0; i < mpi_size; i++) { all_recv_double_data[i].resize((DIM * DIM) * noof_simplices_recv[i] + (DIM)*noof_nodes_recv[i] @@ -391,14 +389,14 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( int simplex_data_offset; - array<size_t, DIM + 1> recv_simplex; + std::array<size_t, DIM + 1> recv_simplex; Point recv_node; Matrix recv_matrix; int node_data_idx_offset = DIM; #ifdef FINITE_TEMPERATURE - array<double, NIDOF> recv_thermal_dof; + std::array<double, NIDOF> recv_thermal_dof; node_data_idx_offset += NIDOF; #endif @@ -534,7 +532,7 @@ void neighbourhoods::updateOverlappingMeshElementsAndNodes( make_move_iterator(added_node_idxs_for_sending[i_proc].end())); } - vector<size_t>().swap(added_simplex_idxs_for_sending[i_proc]); - vector<size_t>().swap(added_node_idxs_for_sending[i_proc]); + std::vector<size_t>().swap(added_simplex_idxs_for_sending[i_proc]); + std::vector<size_t>().swap(added_node_idxs_for_sending[i_proc]); } } diff --git a/src/neighbourhoods/periodicMeshExchange.ipp b/src/neighbourhoods/periodicMeshExchange.ipp index 4cc9c4674..156ce1a8e 100644 --- a/src/neighbourhoods/periodicMeshExchange.ipp +++ b/src/neighbourhoods/periodicMeshExchange.ipp @@ -1,11 +1,11 @@ #pragma once +#include "neighbourhoods.h" #include <uniquePointContainer.h> -using namespace geometry; - template <typename mesh, int DIM, int NIDOF> void neighbourhoods::updatePeriodicMeshElementsAndNodes( - mesh &_local_mesh, const vector<geom::Ball<double, DIM>> &_periodic_balls, + mesh &_local_mesh, + const std::vector<geom::Ball<double, DIM>> &_periodic_balls, const Box<point<DIM>, DIM> &_domain_bounds) { // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// // If refinements happened, @@ -18,14 +18,14 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( // duplicate elements. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// typedef point<DIM> Point; - typedef array<point<DIM>, DIM + 1> Simplex; + typedef std::array<point<DIM>, DIM + 1> Simplex; typedef Eigen::Matrix<double, DIM, DIM> Matrix; typedef geom::Ball<double, DIM> ball; typedef uniquePointContainer<Point, DIM> UniqueContainer; - typedef pair<int, size_t> _pairKey_; + typedef std::pair<int, size_t> _pairKey_; - vector<int> noof_periodic_balls_data(mpi_size, 0); - vector<double> balls_data_to_bcast; + std::vector<int> noof_periodic_balls_data(mpi_size, 0); + std::vector<double> balls_data_to_bcast; int noof_periodic_sampling_atoms = _periodic_balls.size(); @@ -45,7 +45,7 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( // vanilla MPI (use all_gatherv with open-mpi) // first compute the displacements from _N - vector<int> displacements(mpi_size, 0); + std::vector<int> displacements(mpi_size, 0); for (int i_rank = 1; i_rank != mpi_size; ++i_rank) { displacements[i_rank] = displacements[i_rank - 1] + noof_periodic_balls_data[i_rank - 1]; @@ -58,24 +58,24 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( // | | // <-displacement[r]--> - vector<double> balls_data_all_proc(displacements[mpi_size - 1] + - noof_periodic_balls_data[mpi_size - 1]); + std::vector<double> balls_data_all_proc( + displacements[mpi_size - 1] + noof_periodic_balls_data[mpi_size - 1]); // all gather will not work in case // billions of sampling atoms are sending data mpi_utilities::ALLGATHERV<double>(balls_data_to_bcast, balls_data_all_proc, noof_periodic_balls_data, displacements); - vector<int> ball_procs_delimiters(mpi_size + 1, 0); + std::vector<int> ball_procs_delimiters(mpi_size + 1, 0); for (int i = 0; i < mpi_size; i++) { ball_procs_delimiters[i + 1] = displacements[i] / (DIM + 1) + noof_periodic_balls_data[i] / (DIM + 1); } - vector<geom::Ball<double, DIM>> balls_all_proc; + std::vector<geom::Ball<double, DIM>> balls_all_proc; balls_all_proc.reserve(balls_data_all_proc.size() / (DIM + 1)); - vector<vector<int>> ranks_of_uniqueBoundaryBalls; + std::vector<std::vector<int>> ranks_of_uniqueBoundaryBalls; ranks_of_uniqueBoundaryBalls.reserve(balls_data_all_proc.size() / (DIM + 1)); size_t noof_balls_all_proc = balls_data_all_proc.size() / (DIM + 1); @@ -96,7 +96,7 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( int unique_ball_idx, ball_rank; for (int ball_ctr = 0; ball_ctr < noof_balls_all_proc; ball_ctr++) { - const vector<int>::const_iterator it = upper_bound( + const std::vector<int>::const_iterator it = upper_bound( ball_procs_delimiters.cbegin(), ball_procs_delimiters.cend(), ball_ctr); ball_rank = distance(ball_procs_delimiters.cbegin(), it) - 1; @@ -121,7 +121,7 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( if (added) { balls_all_proc.push_back(interproc_ball); - ranks_of_uniqueBoundaryBalls.push_back(vector<int>{ball_rank}); + ranks_of_uniqueBoundaryBalls.push_back(std::vector<int>{ball_rank}); } else { ranks_of_uniqueBoundaryBalls[unique_ball_idx].push_back(ball_rank); } @@ -144,11 +144,11 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( interproc_ball_simplex_query(balls_all_proc.begin(), balls_all_proc.end()); - vector<int> idxs_balls_overlapping; + std::vector<int> idxs_balls_overlapping; idxs_balls_overlapping.reserve(int(balls_all_proc.size() / mpi_size)); - vector<vector<size_t>> added_simplex_idxs_for_sending(mpi_size); - vector<vector<size_t>> added_node_idxs_for_sending(mpi_size); + std::vector<std::vector<size_t>> added_simplex_idxs_for_sending(mpi_size); + std::vector<std::vector<size_t>> added_node_idxs_for_sending(mpi_size); for (int i_proc = 0; i_proc < mpi_size; i_proc++) { added_simplex_idxs_for_sending[i_proc].reserve( @@ -160,8 +160,8 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( Simplex simplex; // store all elements that are in the neighbourhood of boundary balls - vector<vector<size_t>> elementsOfBoundaryBalls(uniqueBoundaryBalls.size(), - vector<size_t>{}); + std::vector<std::vector<size_t>> elementsOfBoundaryBalls( + uniqueBoundaryBalls.size(), std::vector<size_t>{}); for (size_t i_el = 0; i_el != _local_mesh.meshCells_.size(); ++i_el) { simplex = _local_mesh.getSimplex(_local_mesh.simplex_index_to_key_[i_el]); @@ -229,13 +229,13 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( // one by one and receive, with traditional non-blocking MPI_Isend // data to be sent is nodes (coordinates), lattice vectors, // atomistic flags. - vector<vector<double>> all_send_double_data(mpi_size); - vector<vector<int>> all_send_int_data(mpi_size); + std::vector<std::vector<double>> all_send_double_data(mpi_size); + std::vector<std::vector<int>> all_send_int_data(mpi_size); - vector<int> noof_simplices_send(mpi_size, 0); - vector<int> noof_nodes_send(mpi_size, 0); + std::vector<int> noof_simplices_send(mpi_size, 0); + std::vector<int> noof_nodes_send(mpi_size, 0); - vector<double> meshnodes_send; + std::vector<double> meshnodes_send; meshnodes_send.reserve(_local_mesh.meshNodes_.size() * DIM #ifdef FINITE_TEMPERATURE @@ -247,7 +247,7 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( // unordered_set<size_t> added_nodes; - // vector<int> added_nodes_local_indices( + // std::vector<int> added_nodes_local_indices( // _local_mesh.meshNodes_.size(), numeric_limits<int>::max()); size_t cellKey, nodeKey, nodeIndex, sentIndex; @@ -301,8 +301,8 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( _local_mesh.periodicMeshData .overlap_nodes_sent_idx_recv_side_[i_proc] - .insert(make_pair(static_cast<int>(nodeKey), - static_cast<int>(sentIndex))); + .insert(std::make_pair(static_cast<int>(nodeKey), + static_cast<int>(sentIndex))); added_node_idxs_for_sending[i_proc].push_back(nodeIndex); @@ -372,17 +372,17 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( // #endif uniqueBoundaryBalls.clear(); - vector<double>().swap(meshnodes_send); - vector<int> noof_simplices_recv(mpi_size, 0); - vector<int> noof_nodes_recv(mpi_size, 0); + std::vector<double>().swap(meshnodes_send); + std::vector<int> noof_simplices_recv(mpi_size, 0); + std::vector<int> noof_nodes_recv(mpi_size, 0); mpi_utilities::MPIExchangeBuffers_NonBlocking<int>( noof_simplices_send, noof_simplices_recv, mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<int>(noof_nodes_send, noof_nodes_recv, mpi_size); - vector<vector<double>> all_recv_double_data(mpi_size); - vector<vector<int>> all_recv_int_data(mpi_size); + std::vector<std::vector<double>> all_recv_double_data(mpi_size); + std::vector<std::vector<int>> all_recv_int_data(mpi_size); for (int i = 0; i < mpi_size; i++) { all_recv_double_data[i].resize((DIM * DIM) * noof_simplices_recv[i] + (DIM)*noof_nodes_recv[i] @@ -402,14 +402,14 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( int simplex_data_offset; - array<size_t, DIM + 1> recv_simplex; + std::array<size_t, DIM + 1> recv_simplex; Point recv_node; Matrix recv_matrix; int node_data_idx_offset = DIM; #ifdef FINITE_TEMPERATURE - array<double, NIDOF> recv_thermal_dof; + std::array<double, NIDOF> recv_thermal_dof; node_data_idx_offset += NIDOF; #endif @@ -534,7 +534,7 @@ void neighbourhoods::updatePeriodicMeshElementsAndNodes( make_move_iterator(added_node_idxs_for_sending[i_proc].end())); } - vector<size_t>().swap(added_simplex_idxs_for_sending[i_proc]); - vector<size_t>().swap(added_node_idxs_for_sending[i_proc]); + std::vector<size_t>().swap(added_simplex_idxs_for_sending[i_proc]); + std::vector<size_t>().swap(added_node_idxs_for_sending[i_proc]); } -} \ No newline at end of file +} diff --git a/src/neighbourhoods/uniqueBallContainer.h b/src/neighbourhoods/uniqueBallContainer.h index 026f60fe5..24e1cc1b3 100644 --- a/src/neighbourhoods/uniqueBallContainer.h +++ b/src/neighbourhoods/uniqueBallContainer.h @@ -14,23 +14,22 @@ #include "StandardHeaders.h" #include "geometry.h" -using namespace std; - namespace geometry { template <typename object, int DIM> class uniquePointContainer { public: typedef geom::BBox<double, 3> box; - typedef geom::Octree<Dereference<typename vector<point<3>>::const_iterator>> + typedef geom::Octree< + Dereference<typename std::vector<point<3>>::const_iterator>> octree; public: - vector<object> objects_; + std::vector<object> objects_; private: const double tolerance_; box bounds_; octree orq_; - vector<typename vector<point<3>>::const_iterator> points_in_query_; + std::vector<typename std::vector<point<3>>::const_iterator> points_in_query_; public: uniquePointContainer() @@ -108,4 +107,4 @@ public: size_t size() { return objects_.size(); } }; -} // namespace geometry \ No newline at end of file +} // namespace geometry diff --git a/src/neighbourhoods/updateAllNeighbourhoods.ipp b/src/neighbourhoods/updateAllNeighbourhoods.ipp index c12ca3536..f435812c3 100644 --- a/src/neighbourhoods/updateAllNeighbourhoods.ipp +++ b/src/neighbourhoods/updateAllNeighbourhoods.ipp @@ -1,8 +1,5 @@ #pragma once - -// using namespace geom; -using namespace geometry; - +#include "neighbourhoods.h" /*! UpdateNeighbourhoodsAllSamplingAtoms computes neighbourhoods of all sampling atoms in the initial configuration when all elements @@ -16,23 +13,24 @@ template <typename mesh, typename sampling_atom, typename repatom, // typename simulation, int DIM> void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( - mesh &_local_mesh, vector<sampling_atom> &_nodal_sampling_atoms, - vector<sampling_atom> &_cb_sampling_atoms, const vector<repatom> &_repatoms, + mesh &_local_mesh, std::vector<sampling_atom> &_nodal_sampling_atoms, + std::vector<sampling_atom> &_cb_sampling_atoms, + const std::vector<repatom> &_repatoms, const Box<point<DIM>, DIM> &_domain_bounds //, const simulation &_simulation ) { - typedef array<point<DIM>, DIM + 1> Simplex; - typedef array<int, DIM> Face; - typedef pair<int, int> OverlapDataIndex; + typedef std::array<point<DIM>, DIM + 1> Simplex; + typedef std::array<int, DIM> Face; + typedef std::pair<int, int> OverlapDataIndex; typedef lattice::uniqueLatticeSiteContainer<point<DIM>, DIM> uniquePointContainer; typedef geom::Ball<double, DIM> ball; // make sampling atom balls for nodal sampling atoms - vector<ball> sampling_atom_balls; - vector<vector<size_t>> elements_of_sampling_atoms; - vector<vector<OverlapDataIndex>> rcvd_elements_of_sampling_atoms; + std::vector<ball> sampling_atom_balls; + std::vector<std::vector<size_t>> elements_of_sampling_atoms; + std::vector<std::vector<OverlapDataIndex>> rcvd_elements_of_sampling_atoms; elements_of_sampling_atoms.reserve(_nodal_sampling_atoms.size()); sampling_atom_balls.reserve(_nodal_sampling_atoms.size()); @@ -45,7 +43,7 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( atom_ball.radius = _nodal_sampling_atoms[i].r_cut + VerletBuffer; sampling_atom_balls.push_back(atom_ball); - elements_of_sampling_atoms.push_back(vector<size_t>{}); + elements_of_sampling_atoms.push_back(std::vector<size_t>{}); } // build KDTree query for sampling atom balls @@ -59,16 +57,16 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( ball_simplex_query(sampling_atom_balls.begin(), sampling_atom_balls.end()); - vector<int> interproc_sampling_atoms_flag(sampling_atom_balls.size(), 0); + std::vector<int> interproc_sampling_atoms_flag(sampling_atom_balls.size(), 0); - vector<int> index_interproc_vectors(_nodal_sampling_atoms.size(), - numeric_limits<int>::max()); + std::vector<int> index_interproc_vectors(_nodal_sampling_atoms.size(), + std::numeric_limits<int>::max()); // solve query for each element and store the // elements of sampling atoms // indices of balls that overlap a given element - vector<size_t> idxs_balls_overlapping; + std::vector<size_t> idxs_balls_overlapping; idxs_balls_overlapping.reserve(_nodal_sampling_atoms.size()); Simplex simplex; @@ -133,7 +131,7 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( interproc_sampling_atoms_flag.end(), 0); rcvd_elements_of_sampling_atoms.resize(_nodal_sampling_atoms.size(), - vector<OverlapDataIndex>{}); + std::vector<OverlapDataIndex>{}); // // exchange mesh from idx_interproc_sampling_atoms // neighbourhoods::InitializeOverlappingMeshElements<mesh, sampling_atom, @@ -158,7 +156,7 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( _local_mesh.overlappingMeshData.overlapping_simplices_recv_[i_proc] .size(); i_el_recv++) { - index_pair = make_pair(i_proc, i_el_recv); + index_pair = std::make_pair(i_proc, i_el_recv); _local_mesh.getOverlappingSimplex(index_pair, simplex); @@ -203,8 +201,8 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( int recv_rank_idx; int recv_simplex_idx; bool added; - array<double, DIM + 1> N_j; - array<double, DIM + 1> N_alpha; + std::array<double, DIM + 1> N_j; + std::array<double, DIM + 1> N_alpha; uniquePointContainer neighbourhood_container; neighbourhood_container.reserve(_nodal_sampling_atoms.size()); @@ -212,9 +210,9 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( neighbourhood_container.initialize(sampling_atom_balls[0].center, sampling_atom_balls[0].radius); - typename vector<ball>::const_iterator ballsIterator; - vector<size_t>::const_iterator sizeIterator; - vector<OverlapDataIndex>::const_iterator pairIDIterator; + typename std::vector<ball>::const_iterator ballsIterator; + std::vector<size_t>::const_iterator sizeIterator; + std::vector<OverlapDataIndex>::const_iterator pairIDIterator; size_t ballIndex; for (ballsIterator = sampling_atom_balls.cbegin(); @@ -333,7 +331,7 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( } } - // vector<point<DIM>> local_neighbours; + // std::vector<point<DIM>> local_neighbours; // local_neighbours.reserve(_repatoms.size()); // for(const repatom &atom : _repatoms) @@ -380,4 +378,4 @@ void neighbourhoods::UpdateNeighbourhoodsAllSamplingAtoms( // _nodal_sampling_atoms[magic_index].neighbour_sites_[in].interproc_flag_<<endl; // } // } -} \ No newline at end of file +} diff --git a/src/orq/simplex_distance.h b/src/orq/simplex_distance.h index f8492adcc..a79bf6d3c 100644 --- a/src/orq/simplex_distance.h +++ b/src/orq/simplex_distance.h @@ -13,7 +13,6 @@ #include "SquareMatrix.h" -// using namespace geometry; typedef geometry::line Line_2; template <typename T> using Plane = geometry::plane<T>; diff --git a/src/orq/uniquePointContainer.h b/src/orq/uniquePointContainer.h index 477bf564d..75817d1df 100644 --- a/src/orq/uniquePointContainer.h +++ b/src/orq/uniquePointContainer.h @@ -14,23 +14,22 @@ #include "StandardHeaders.h" #include "geometry.h" -using namespace std; - namespace geometry { template <typename object, int DIM> class uniquePointContainer { public: typedef geom::BBox<double, 3> box; - typedef geom::Octree<Dereference<typename vector<point<3>>::const_iterator>> + typedef geom::Octree< + Dereference<typename std::vector<point<3>>::const_iterator>> octree; public: - vector<object> objects_; + std::vector<object> objects_; private: const double tolerance_; box bounds_; octree orq_; - vector<typename vector<point<3>>::const_iterator> points_in_query_; + std::vector<typename std::vector<point<3>>::const_iterator> points_in_query_; public: uniquePointContainer() @@ -52,7 +51,7 @@ public: } ~uniquePointContainer() { - vector<object>().swap(objects_); + std::vector<object>().swap(objects_); // orq_.reset(); } void reserve(const size_t &_max_capacity) { objects_.reserve(_max_capacity); } @@ -133,7 +132,7 @@ public: size_t size() { return objects_.size(); } void clear() { - vector<object>().swap(objects_); + std::vector<object>().swap(objects_); orq_.reset(bounds_); } @@ -141,4 +140,4 @@ public: object operator[](const int &i) { return objects_[i]; } }; -} // namespace geometry \ No newline at end of file +} // namespace geometry diff --git a/src/pnetwriter/ReadMesh.ipp b/src/pnetwriter/ReadMesh.ipp index 60f08734d..01161c13a 100644 --- a/src/pnetwriter/ReadMesh.ipp +++ b/src/pnetwriter/ReadMesh.ipp @@ -1,8 +1,10 @@ +#pragma once +#include "pnetIO.h" template <typename mesh, int DIM> void restart::ReadMeshFileParallel(mesh &_local_mesh, bool &_reassign_lattice_vectors, - const string &_filename) { + const std::string &_filename) { unsigned int noofLocalCells; int rankDelimiters[mpi_size + 1]; @@ -22,7 +24,7 @@ void restart::ReadMeshFileParallel(mesh &_local_mesh, &ncfile); ERR - vector<double> + std::vector<double> atomisticBox(2 * DIM); err = ncmpi_get_att_double(ncfile, NC_GLOBAL, "atomist domain box", @@ -53,7 +55,7 @@ void restart::ReadMeshFileParallel(mesh &_local_mesh, err = ncmpi_inq_varid(ncfile, "cell and nodes", &varid); ERR - vector<unsigned int> + std::vector<unsigned int> elementAndNodeIDs( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * dim_sizes[1]); @@ -74,7 +76,7 @@ void restart::ReadMeshFileParallel(mesh &_local_mesh, &saved_lattice_vectors); ERR - vector<double> + std::vector<double> elementLatticeVectors; _reassign_lattice_vectors = true; @@ -112,7 +114,7 @@ void restart::ReadMeshFileParallel(mesh &_local_mesh, err = ncmpi_inq_varid(ncfile, "node keys material ids", &varid); ERR - vector<unsigned int> + std::vector<unsigned int> nodeIDsAndMaterialIndices( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * dim_sizes[1]); @@ -136,7 +138,7 @@ void restart::ReadMeshFileParallel(mesh &_local_mesh, assert(dim_sizes[1] == DIM); - vector<double> nodeCoordinates( + std::vector<double> nodeCoordinates( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * dim_sizes[1]); count[1] = dim_sizes[1]; diff --git a/src/pnetwriter/ReadRestart.ipp b/src/pnetwriter/ReadRestart.ipp index d34c8f019..25353bc82 100644 --- a/src/pnetwriter/ReadRestart.ipp +++ b/src/pnetwriter/ReadRestart.ipp @@ -1,3 +1,4 @@ +#pragma once #include "mesh.h" #include "pnetIO.h" @@ -77,7 +78,7 @@ void restart::ReadRestartFileParallel(mesh &_local_mesh) { // (rankDelimiters[mpi_rank + 1] - // rankDelimiters[mpi_rank])*dim_sizes[1]]; - vector<unsigned int> + std::vector<unsigned int> elementAndNodeIDs( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * dim_sizes[1]); @@ -105,7 +106,7 @@ void restart::ReadRestartFileParallel(mesh &_local_mesh) { // (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank])* // static_cast<int>(dim_sizes[1])]; - vector<double> + std::vector<double> elementData( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * static_cast<int>(dim_sizes[1])); @@ -139,7 +140,7 @@ void restart::ReadRestartFileParallel(mesh &_local_mesh) { // (rankDelimiters[mpi_rank +1 ] - // rankDelimiters[mpi_rank])*dim_sizes[1]]; - vector<unsigned int> + std::vector<unsigned int> nodeIDsAndMaterialIndices( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * dim_sizes[1]); @@ -165,7 +166,7 @@ void restart::ReadRestartFileParallel(mesh &_local_mesh) { // double nodeCoordinates[ // (rankDelimiters[mpi_rank +1 ] - rankDelimiters[mpi_rank])*dim_sizes[1]]; - vector<double> nodeCoordinates( + std::vector<double> nodeCoordinates( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * dim_sizes[1]); count[1] = dim_sizes[1]; @@ -184,7 +185,7 @@ void restart::ReadRestartFileParallel(mesh &_local_mesh) { // double nodeThermalDOFs[ // (rankDelimiters[mpi_rank +1 ] - // rankDelimiters[mpi_rank])*dim_sizes[1]]; - vector<double> + std::vector<double> nodeThermalDOFs( (rankDelimiters[mpi_rank + 1] - rankDelimiters[mpi_rank]) * dim_sizes[1]); @@ -198,7 +199,7 @@ void restart::ReadRestartFileParallel(mesh &_local_mesh) { // err = ncmpi_get_att_int(ncfile, NC_GLOBAL, // "number of zones", &N_zones); ERR - string boundary_attribute; + std::string boundary_attribute; // // assign boundary conditions from here // for(int i_zone=0; i_zone<N_zones; i_zone++) @@ -248,9 +249,10 @@ void restart::ReadRestartFileParallel(mesh &_local_mesh) { template <int DIM> void restart::ReadBoundariesFromMeshFile( - int &_N_zones, vector<string> &_boundary_types, - vector<double> &_boundary_bounds, vector<int> &_boundary_coordinates, - vector<array<double, DIM>> &_boundary_normals) { + int &_N_zones, std::vector<std::string> &_boundary_types, + std::vector<double> &_boundary_bounds, + std::vector<int> &_boundary_coordinates, + std::vector<std::array<double, DIM>> &_boundary_normals) { int ncfile, err, nerrs, ncid; MPI_Offset attribute_string_lengths; @@ -264,18 +266,18 @@ void restart::ReadBoundariesFromMeshFile( char *attribute_string; char buffer[256]; - string boundary_attribute; + std::string boundary_attribute; _boundary_types.resize(_N_zones); _boundary_bounds.resize(_N_zones); _boundary_coordinates.resize(_N_zones); _boundary_normals.resize(_N_zones); - stringstream ss; + std::stringstream ss; for (int i_zone = 0; i_zone < _N_zones; i_zone++) { sprintf(buffer, "%02d", i_zone + 1); - string boundary_attribute_number(buffer); + std::string boundary_attribute_number(buffer); boundary_attribute = "boundaryType_" + boundary_attribute_number; @@ -288,7 +290,7 @@ void restart::ReadBoundariesFromMeshFile( attribute_string); ERR - _boundary_types[i_zone] = string(attribute_string); + _boundary_types[i_zone] = std::string(attribute_string); boundary_attribute = "bounds_" + boundary_attribute_number; err = ncmpi_get_att_double(ncfile, NC_GLOBAL, boundary_attribute.c_str(), @@ -310,11 +312,9 @@ void restart::ReadBoundariesFromMeshFile( } template <int DIM> -void restart::ReadExternalForceApplicator(string &_external_applicator_name, - array<double, DIM> &_center, - double &_radius, - double &_force_constant, - double &_delta) { +void restart::ReadExternalForceApplicator( + std::string &_external_applicator_name, std::array<double, DIM> &_center, + double &_radius, double &_force_constant, double &_delta) { /*************** <READING EXTERNAL FORCE APPLICATOR STATUS FROM RESTART FILE> * ***********************/ int err, nerrs = 0; @@ -337,7 +337,7 @@ void restart::ReadExternalForceApplicator(string &_external_applicator_name, attribute_string); ERR - _external_applicator_name = string(attribute_string); + _external_applicator_name = std::string(attribute_string); err = ncmpi_get_att_double(ncfile, NC_GLOBAL, "force applicator center", &_center[0]); @@ -376,10 +376,10 @@ void restart::ReadExternalForceApplicator(string &_external_applicator_name, // int var_ndims, var_natts, local_noof_elements; // nc_type type; -// vector<int> dimids(2); -// vector<int> dimids_bravais_vectors(2); +// std::vector<int> dimids(2); +// std::vector<int> dimids_bravais_vectors(2); -// vector<MPI_Offset> dim_sizes(2), +// std::vector<MPI_Offset> dim_sizes(2), // dim_sizes_bravais_vectors(2), start(2), count(2); // MPI_Offset var_size; @@ -436,9 +436,9 @@ void restart::ReadExternalForceApplicator(string &_external_applicator_name, // (global_noof_elements/mpi_size)*(mpi_size-1); // } -// vector<int> local_ids_and_nodes((DIM + 2)*local_noof_elements); -// vector<double> element_bravais_vectors(DIM*DIM*local_noof_elements); -// vector<double> element_densities((DIM + 1)*local_noof_elements); +// std::vector<int> local_ids_and_nodes((DIM + 2)*local_noof_elements); +// std::vector<double> element_bravais_vectors(DIM*DIM*local_noof_elements); +// std::vector<double> element_densities((DIM + 1)*local_noof_elements); // start[0] = (global_noof_elements/mpi_size)*mpi_rank; // count[0] = local_noof_elements; @@ -491,7 +491,7 @@ void restart::ReadExternalForceApplicator(string &_external_applicator_name, // (global_read_edges/mpi_size)*(mpi_size-1); // } -// vector<int> local_ids_and_neighbours((2 + 1)*local_noof_edges); +// std::vector<int> local_ids_and_neighbours((2 + 1)*local_noof_edges); // start[0] = (global_read_edges/mpi_size)*mpi_rank; // count[0] = local_noof_edges; @@ -534,11 +534,11 @@ void restart::ReadExternalForceApplicator(string &_external_applicator_name, // (global_read_nodes/mpi_size)*(mpi_size-1); // } -// vector<int> local_node_ids(local_noof_nodes); -// vector<int> local_node_material_ids(local_noof_nodes); +// std::vector<int> local_node_ids(local_noof_nodes); +// std::vector<int> local_node_material_ids(local_noof_nodes); -// vector<double> global_coords((DIM)*local_noof_nodes); -// vector<double> global_velocities((DIM)*local_noof_nodes); +// std::vector<double> global_coords((DIM)*local_noof_nodes); +// std::vector<double> global_velocities((DIM)*local_noof_nodes); // start[0] = (global_read_nodes/mpi_size)*mpi_rank; // count[0] = local_noof_nodes; @@ -665,7 +665,7 @@ void restart::ReadExternalForceApplicator(string &_external_applicator_name, // _global_mesh.ShuffleAllElements(); // template<int DIM> -// void restart::ReadCellsParallel(vector<int> &_cell_data_to_read) +// void restart::ReadCellsParallel(std::vector<int> &_cell_data_to_read) // { // int pnet_iter = 0; // char buffer[256]; @@ -716,12 +716,12 @@ void restart::ReadExternalForceApplicator(string &_external_applicator_name, // } template <int DIM> -void restart::ReadNodesParallel(vector<double> &_node_data_to_read) { +void restart::ReadNodesParallel(std::vector<double> &_node_data_to_read) { int pnet_iter = 0; char buffer[256]; sprintf(buffer, "%06d", pnet_iter); - string output_iter(buffer); - string restart_file_name = + std::string output_iter(buffer); + std::string restart_file_name = "./restart_files/restart_" + output_iter + "_prototype.nc"; int ncfile, unlimited, err, varid, nerrs, global_noof_elements; @@ -767,4 +767,4 @@ void restart::ReadNodesParallel(vector<double> &_node_data_to_read) { ERR err = ncmpi_close(ncfile); -} \ No newline at end of file +} diff --git a/src/pnetwriter/WriteMesh.ipp b/src/pnetwriter/WriteMesh.ipp index d6112e26f..4a1b9709c 100644 --- a/src/pnetwriter/WriteMesh.ipp +++ b/src/pnetwriter/WriteMesh.ipp @@ -1,8 +1,9 @@ +#pragma once #include "pnetIO.h" template <typename mesh, int DIM> void restart::WriteMeshParallel(const mesh &_local_mesh, - const string &_outFileName, + const std::string &_outFileName, bool save_lattice_vectors) { int saved_lattice_vectors = int(save_lattice_vectors); @@ -10,26 +11,26 @@ void restart::WriteMeshParallel(const mesh &_local_mesh, _local_mesh.meshNodes_.size() - _local_mesh.globalGhostIndices_.size(); size_t noof_local_cells = _local_mesh.meshCells_.size(); - vector<double> mesh_node_data(noof_local_nodes * DIM); - vector<unsigned int> node_int_data(noof_local_nodes * 2); + std::vector<double> mesh_node_data(noof_local_nodes * DIM); + std::vector<unsigned int> node_int_data(noof_local_nodes * 2); // unsigned int node_int_data[noof_local_nodes*2]; size_t nVar_int_nodes = 2; // size_t mesh_node_int_data[noof_local_nodes*nVar_int_nodes]; - vector<size_t> mesh_node_int_data(noof_local_nodes * nVar_int_nodes); + std::vector<size_t> mesh_node_int_data(noof_local_nodes * nVar_int_nodes); - vector<unsigned int> mesh_id_data(noof_local_cells * - size_t(mesh::SIMPLEX_DIMENSION_ + 1 + 1)); + std::vector<unsigned int> mesh_id_data( + noof_local_cells * size_t(mesh::SIMPLEX_DIMENSION_ + 1 + 1)); - vector<double> cellLatticeVectors; - vector<double> meshAtomisticDomain(2 * DIM); + std::vector<double> cellLatticeVectors; + std::vector<double> meshAtomisticDomain(2 * DIM); size_t cellDataIdx = 0; size_t nodeDataIdx = 0; size_t cellKey; - array<double, DIM> point; + std::array<double, DIM> point; for (int d = 0; d < DIM; d++) { meshAtomisticDomain[d] = _local_mesh.atomisticDomain_.upper_[d]; @@ -109,7 +110,7 @@ void restart::WriteMeshParallel(const mesh &_local_mesh, int pnet_file_mode = NC_CLOBBER | NC_64BIT_DATA; - string filename = _outFileName + ".nc"; + std::string filename = _outFileName + ".nc"; err = ncmpi_create(MPI_COMM_WORLD, filename.c_str(), pnet_file_mode, MPI_INFO_NULL, &ncid); @@ -279,9 +280,9 @@ void restart::WriteMeshElementsParallel(const mesh &_local_mesh, restart::CalcCummulativeDimensions(static_cast<int>(local_noofelements), noof_cummulative_elements); - vector<int> dimid(nc_dims); + std::vector<int> dimid(nc_dims); - string mesh_file_name = "./mesh_files/Elements.nc"; + std::string mesh_file_name = "./mesh_files/Elements.nc"; cmode = NC_CLOBBER | NC_64BIT_DATA; err = ncmpi_create(MPI_COMM_WORLD, mesh_file_name.c_str(), cmode, MPI_INFO_NULL, &ncid); @@ -307,13 +308,13 @@ void restart::WriteMeshElementsParallel(const mesh &_local_mesh, * and global ids of vertices */ - vector<int> + std::vector<int> array_of_sizes(2); - vector<int> array_of_subsizes(2); - vector<int> array_of_starts(2); + std::vector<int> array_of_subsizes(2); + std::vector<int> array_of_starts(2); - vector<MPI_Offset> start(2); - vector<MPI_Offset> count(2); + std::vector<MPI_Offset> start(2); + std::vector<MPI_Offset> count(2); array_of_sizes[1] = (DIM + 1) + 1; array_of_sizes[0] = static_cast<int>(local_noofelements); @@ -337,7 +338,7 @@ void restart::WriteMeshElementsParallel(const mesh &_local_mesh, &subarray); MPI_Type_commit(&subarray); - vector<int> element_data; + std::vector<int> element_data; element_data.resize(local_noofelements * ((DIM + 1) + 1)); int ctr = 0; for (int i = 0; i < local_noofelements; i++) { @@ -387,9 +388,9 @@ void restart::WriteMeshFacesParallel(const mesh &_local_mesh, noof_global_edges_unique = static_cast<int>(_global_mesh.NoofFaces); - vector<int> dimid(nc_dims); + std::vector<int> dimid(nc_dims); - string mesh_file_name = "./mesh_files/Edges.nc"; + std::string mesh_file_name = "./mesh_files/Edges.nc"; cmode = NC_CLOBBER | NC_64BIT_DATA; err = ncmpi_create(MPI_COMM_WORLD, mesh_file_name.c_str(), cmode, MPI_INFO_NULL, &ncid); @@ -415,13 +416,13 @@ void restart::WriteMeshFacesParallel(const mesh &_local_mesh, * and global ids of vertices */ - vector<int> + std::vector<int> array_of_sizes(2); - vector<int> array_of_subsizes(2); - vector<int> array_of_starts(2); + std::vector<int> array_of_subsizes(2); + std::vector<int> array_of_starts(2); - vector<MPI_Offset> start(2); - vector<MPI_Offset> count(2); + std::vector<MPI_Offset> start(2); + std::vector<MPI_Offset> count(2); array_of_sizes[1] = 3; array_of_sizes[0] = static_cast<int>(local_noofedges); @@ -445,7 +446,7 @@ void restart::WriteMeshFacesParallel(const mesh &_local_mesh, &subarray); MPI_Type_commit(&subarray); - vector<int> edge_data; + std::vector<int> edge_data; edge_data.resize(local_noofedges * (2 + 1)); int ctr = 0; @@ -508,9 +509,9 @@ void restart::WriteMeshNodesParallel(const mesh &_local_mesh, noof_global_nodes_unique = static_cast<int>(_global_mesh.NoofNodes); - vector<int> dimid(nc_dims); + std::vector<int> dimid(nc_dims); - string mesh_file_name = "./mesh_files/Nodes.nc"; + std::string mesh_file_name = "./mesh_files/Nodes.nc"; cmode = NC_CLOBBER | NC_64BIT_DATA; err = ncmpi_create(MPI_COMM_WORLD, mesh_file_name.c_str(), cmode, MPI_INFO_NULL, &ncid); @@ -542,7 +543,7 @@ void restart::WriteMeshNodesParallel(const mesh &_local_mesh, * Writing element global ids * and global ids of vertices */ - vector<restart::MeshNodesData<DIM>> + std::vector<restart::MeshNodesData<DIM>> nodes_id_coordinates(local_noofnodes); for (int nd = 0; nd < local_noofnodes; nd++) { @@ -571,12 +572,12 @@ void restart::WriteMeshNodesParallel(const mesh &_local_mesh, MPI_Type_create_struct(2, block_lengths, disp, type, &node_data_type); MPI_Type_commit(&node_data_type); - vector<int> array_of_sizes(2); - vector<int> array_of_subsizes(2); - vector<int> array_of_starts(2); + std::vector<int> array_of_sizes(2); + std::vector<int> array_of_subsizes(2); + std::vector<int> array_of_starts(2); - vector<MPI_Offset> start(2); - vector<MPI_Offset> count(2); + std::vector<MPI_Offset> start(2); + std::vector<MPI_Offset> count(2); array_of_sizes[0] = static_cast<int>(local_noofnodes); array_of_sizes[1] = DIM; @@ -605,8 +606,8 @@ void restart::WriteMeshNodesParallel(const mesh &_local_mesh, &subarray_coords); MPI_Type_commit(&subarray_coords); - vector<int> node_ids(local_noofnodes); - vector<double> node_coords(DIM * local_noofnodes); + std::vector<int> node_ids(local_noofnodes); + std::vector<double> node_coords(DIM * local_noofnodes); int node_coords_ctr = 0; for (int i = 0; i < local_noofnodes; i++) { diff --git a/src/pnetwriter/WriteRestart.ipp b/src/pnetwriter/WriteRestart.ipp index c5902c461..7b3502f5c 100644 --- a/src/pnetwriter/WriteRestart.ipp +++ b/src/pnetwriter/WriteRestart.ipp @@ -1,9 +1,11 @@ +#pragma once #include "pnetIO.h" template <typename mesh, typename boundary_condition, typename external_force_applicator, int DIM> void restart::WriteRestartFileParallel( - const mesh &_local_mesh, const vector<boundary_condition *> &_boundaries, + const mesh &_local_mesh, + const std::vector<boundary_condition *> &_boundaries, const external_force_applicator *_external_force_applicator, bool _if_initial_mesh_file) { @@ -19,8 +21,8 @@ void restart::WriteRestartFileParallel( */ char buffer[256]; sprintf(buffer, "%06d", restartfile_iter); - string output_iter(buffer); - string restart_file_name; + std::string output_iter(buffer); + std::string restart_file_name; if (_if_initial_mesh_file) { restart_file_name = "./InitialMesh.nc"; @@ -49,8 +51,8 @@ void restart::WriteRestartFileParallel( size_t node_double_data_size = static_cast<size_t>(DIM + 1); size_t nVar_int_nodes = 3; - vector<double> mesh_node_data; - vector<double> cells_data; + std::vector<double> mesh_node_data; + std::vector<double> cells_data; cells_data.reserve(noof_write_cells * (cell_data_size)); mesh_node_data.reserve(noof_write_nodes * node_double_data_size); @@ -59,14 +61,14 @@ void restart::WriteRestartFileParallel( // sampling atom ) #ifdef FINITE_TEMPERATURE - vector<double> mesh_node_IDOFS; + std::vector<double> mesh_node_IDOFS; mesh_node_IDOFS.reserve(noof_write_nodes * (mesh::THERMAL_DOFS_ + 1)); // entropy is not counted as a "degree of freedom" // for relaxation. THERMAL_DOFS_ are only Omega and Sigma #endif - vector<unsigned int> node_int_data; - vector<unsigned int> mesh_id_data; + std::vector<unsigned int> node_int_data; + std::vector<unsigned int> mesh_id_data; node_int_data.reserve(noof_write_nodes * nVar_int_nodes); mesh_id_data.reserve(noof_write_cells * (mesh::SIMPLEX_DIMENSION_ + 1 + 1)); @@ -76,7 +78,7 @@ void restart::WriteRestartFileParallel( size_t cellKey; - array<double, DIM> point; + std::array<double, DIM> point; for (size_t nodeIndex = 0; nodeIndex < _local_mesh.meshNodes_.size(); nodeIndex++) { @@ -343,7 +345,7 @@ void restart::WriteRestartFileParallel( err = ncmpi_wait_all(ncid, numOutputVars, &req_nodes, &istatus_nodes); #endif - string boundary_attribute; + std::string boundary_attribute; err = ncmpi_redef(ncid); ERR @@ -373,7 +375,7 @@ void restart::WriteRestartFileParallel( // output boundary constraints/conditions for (int i_zone = 0; i_zone < N_zones; i_zone++) { sprintf(buffer, "%02d", i_zone + 1); - string boundary_attribute_number(buffer); + std::string boundary_attribute_number(buffer); // boundary_attribute = "boundaryName_"+boundary_attribute_number; @@ -460,9 +462,9 @@ void restart::WriteRestartFileParallel( // static_cast<int>(local_noofelements), // noof_cummulative_elements); - // vector<int> dimid(nc_dims); - // vector<int> dim_vectors(nc_dims); - // vector<int> dim_densities(nc_dims); + // std::vector<int> dimid(nc_dims); + // std::vector<int> dim_vectors(nc_dims); + // std::vector<int> dim_densities(nc_dims); // cmode = NC_CLOBBER | NC_64BIT_DATA; // err = ncmpi_create(MPI_COMM_WORLD, restart_file_name.c_str(), @@ -512,12 +514,12 @@ void restart::WriteRestartFileParallel( // * and global ids of vertices // */ - // vector<int> array_of_sizes(2); - // vector<int> array_of_subsizes(2); - // vector<int> array_of_starts(2); + // std::vector<int> array_of_sizes(2); + // std::vector<int> array_of_subsizes(2); + // std::vector<int> array_of_starts(2); - // vector<MPI_Offset> start(2); - // vector<MPI_Offset> count(2); + // std::vector<MPI_Offset> start(2); + // std::vector<MPI_Offset> count(2); // array_of_sizes[1] = (DIM+1) + 1; // array_of_sizes[0] = static_cast<int>(local_noofelements); @@ -543,9 +545,9 @@ void restart::WriteRestartFileParallel( // &(array_of_starts[0]), MPI_ORDER_C, MPI_INT, &subarray_elements); // MPI_Type_commit(&subarray_elements); - // vector<int> element_data; - // vector<double> element_bravais_vectors; - // vector<double> element_densities; + // std::vector<int> element_data; + // std::vector<double> element_bravais_vectors; + // std::vector<double> element_densities; // element_data.resize(local_noofelements*((DIM+1) + 1)); // element_bravais_vectors.resize(local_noofelements*DIM*DIM); @@ -676,7 +678,7 @@ void restart::WriteRestartFileParallel( // noof_global_edges_unique = // static_cast<int>(_global_mesh.NoofFaces); - // vector<int> dimid_edges(2); + // std::vector<int> dimid_edges(2); // err = ncmpi_open(MPI_COMM_WORLD, restart_file_name.c_str(), // NC_WRITE, MPI_INFO_NULL, &ncid); ERR @@ -715,7 +717,7 @@ void restart::WriteRestartFileParallel( // &(array_of_starts[0]), MPI_ORDER_C, MPI_INT, &subarray_edges); // MPI_Type_commit(&subarray_edges); - // vector<int> edge_data; + // std::vector<int> edge_data; // edge_data.resize(local_noofedges*(2 + 1)); // ctr=0; @@ -781,7 +783,7 @@ void restart::WriteRestartFileParallel( // noof_global_nodes_unique = // static_cast<int>(_global_mesh.NoofNodes); - // vector<int> dimid_nodes(2); + // std::vector<int> dimid_nodes(2); // err = ncmpi_open(MPI_COMM_WORLD, restart_file_name.c_str(), // NC_WRITE, MPI_INFO_NULL, &ncid); ERR @@ -840,11 +842,11 @@ void restart::WriteRestartFileParallel( // &(array_of_starts[0]), MPI_ORDER_C, MPI_DOUBLE, &subarray_coords); // MPI_Type_commit(&subarray_coords); - // vector<int> node_ids(local_noofnodes); - // vector<int> node_material_ids(local_noofnodes); - // vector<double> node_coords(DIM*local_noofnodes); - // vector<double> node_velocities(DIM*local_noofnodes); - // vector<double> node_forces(DIM*local_noofnodes); + // std::vector<int> node_ids(local_noofnodes); + // std::vector<int> node_material_ids(local_noofnodes); + // std::vector<double> node_coords(DIM*local_noofnodes); + // std::vector<double> node_velocities(DIM*local_noofnodes); + // std::vector<double> node_forces(DIM*local_noofnodes); // int node_coords_ctr = 0; // for(int i=0; i<local_noofnodes; i++) @@ -901,7 +903,7 @@ void restart::WriteRestartFileParallel( // // write zones and the repatom indices of that zone // int varid_boundary_node_ids; - // vector<int> global_node_ids(N_zones); + // std::vector<int> global_node_ids(N_zones); // err = ncmpi_open(MPI_COMM_WORLD, restart_file_name.c_str(), // NC_WRITE, MPI_INFO_NULL, &ncid); ERR @@ -911,13 +913,13 @@ void restart::WriteRestartFileParallel( // err = ncmpi_put_att_int(ncid, NC_GLOBAL, // "Total bounding zones", NC_INT, 1, &N_zones); ERR - // vector<int> dimid_zone_nodes(N_zones); + // std::vector<int> dimid_zone_nodes(N_zones); // int noof_global_nodes_in_zone, // noof_cummulative_global_nodes_in_zone; // err = ncmpi_enddef(ncid); ERR - // vector<int> boundary_node_ids; + // std::vector<int> boundary_node_ids; // for(int i_zone=0; i_zone<N_zones; i_zone++) // { @@ -1003,4 +1005,4 @@ void restart::WriteRestartFileParallel( // { // restartfile_iter++; // } -} \ No newline at end of file +} diff --git a/src/pnetwriter/pnetIO.h b/src/pnetwriter/pnetIO.h index d5d4efa84..03f36c5e8 100644 --- a/src/pnetwriter/pnetIO.h +++ b/src/pnetwriter/pnetIO.h @@ -21,12 +21,13 @@ template <typename T> void CalcTotalSizeOfDimensions(const T &, T &); template <typename T> void CalcCummulativeDimensions(const T &, T &); template <typename QCMesh, int DIM> -void WriteMeshParallel(const QCMesh &_local_mesh, const string &, +void WriteMeshParallel(const QCMesh &_local_mesh, const std::string &, bool save_lattice_vectors = false); -template <int DIM> void ReadCellsParallel(vector<int> &_cell_data_to_read); +template <int DIM> void ReadCellsParallel(std::vector<int> &_cell_data_to_read); -template <int DIM> void ReadNodesParallel(vector<double> &_node_data_to_read); +template <int DIM> +void ReadNodesParallel(std::vector<double> &_node_data_to_read); template <typename mesh, int DIM> void WriteMeshElementsParallel(const mesh &, const mesh &); @@ -40,56 +41,56 @@ void WriteMeshNodesParallel(const mesh &, const mesh &); template <typename mesh, typename boundary_condition, typename external_force_applicator, int DIM> void WriteRestartFileParallel(const mesh &, - const vector<boundary_condition *> &, + const std::vector<boundary_condition *> &, const external_force_applicator *, bool _if_initial_mesh_file = false); template <typename mesh, int DIM> void ReadRestartFileParallel(mesh &); template <int DIM> -void ReadBoundariesFromMeshFile(int &, vector<string> &_boundary_types, - vector<double> &_boundary_bounds, - vector<int> &_boundary_coordinates, - vector<array<double, DIM>> &_boundary_normals); +void ReadBoundariesFromMeshFile( + int &, std::vector<std::string> &_boundary_types, + std::vector<double> &_boundary_bounds, + std::vector<int> &_boundary_coordinates, + std::vector<std::array<double, DIM>> &_boundary_normals); template <typename mesh, int DIM> -void ReadMeshFileParallel(mesh &, bool &, const string &_filename); +void ReadMeshFileParallel(mesh &, bool &, const std::string &_filename); template <typename mesh, int DIM> -void rearrangeMeshFromRestart(mesh &_local_mesh, - const bool &_reassign_lattice_vectors, - const unsigned int &noofNodesRead, - const unsigned int &noofLocalCells, - const vector<unsigned int> &nodeIDs, - const vector<double> &coordinates, - const vector<unsigned int> &elementIDs, - const vector<double> &element_lattice_vectors); +void rearrangeMeshFromRestart( + mesh &_local_mesh, const bool &_reassign_lattice_vectors, + const unsigned int &noofNodesRead, const unsigned int &noofLocalCells, + const std::vector<unsigned int> &nodeIDs, + const std::vector<double> &coordinates, + const std::vector<unsigned int> &elementIDs, + const std::vector<double> &element_lattice_vectors); template <typename mesh, int DIM> void rearrangeMeshFromRestart(mesh &_local_mesh, const unsigned int &noofNodesRead, const unsigned int &noofLocalCells, - const vector<unsigned int> &nodeIDs, - const vector<double> &coordinates, + const std::vector<unsigned int> &nodeIDs, + const std::vector<double> &coordinates, #ifdef FINITE_TEMPERATURE - const vector<double> &thermalCoordinates, + const std::vector<double> &thermalCoordinates, #endif - const vector<unsigned int> &elementIDs, - const vector<double> &elementData); + const std::vector<unsigned int> &elementIDs, + const std::vector<double> &elementData); template <int DIM> -void ReadExternalForceApplicator(string &, array<double, DIM> &, double &, - double &, double &); +void ReadExternalForceApplicator(std::string &, std::array<double, DIM> &, + double &, double &, double &); template <typename vector_d, int DIM> -void GatherAllReadVectors(const vector<double> &, const vector<int> &, - vector<vector_d> &); +void GatherAllReadVectors(const std::vector<double> &, const std::vector<int> &, + std::vector<vector_d> &); template <typename mesh, int DIM> void WriteDomainParallel(mesh &); template <int DIM> struct MeshNodesData { // int node_id; - // vector<double> coordinates; + // std::vector<double> coordinates; }; template <> struct MeshNodesData<2> { @@ -115,7 +116,7 @@ void restart::CalcCummulativeDimensions(const T &_local_size, T &_cummulative_size) { _cummulative_size = 0; - vector<T> local_sizes(mpi_size, 0); + std::vector<T> local_sizes(mpi_size, 0); mpi_utilities::ALLGATHER1D<T>(_local_size, local_sizes); @@ -128,4 +129,4 @@ void restart::CalcCummulativeDimensions(const T &_local_size, #include "ReadRestart.ipp" #include "WriteMesh.ipp" #include "WriteRestart.ipp" -#include "rearrangeMeshFromRestart.ipp" \ No newline at end of file +#include "rearrangeMeshFromRestart.ipp" diff --git a/src/pnetwriter/rearrangeMeshFromRestart.ipp b/src/pnetwriter/rearrangeMeshFromRestart.ipp index 3de429636..9e8b2d372 100644 --- a/src/pnetwriter/rearrangeMeshFromRestart.ipp +++ b/src/pnetwriter/rearrangeMeshFromRestart.ipp @@ -1,15 +1,18 @@ +#pragma once +#include "pnetIO.h" + template <typename mesh, int DIM> void restart::rearrangeMeshFromRestart( mesh &_local_mesh, const bool &_reassign_lattice_vectors, const unsigned int &localNodesRead, const unsigned int &noofLocalCells, - const vector<unsigned int> &nodeIDsAndMaterialIndices, - const vector<double> &nodeCoordinates, - const vector<unsigned int> &elementAndNodeIDs, - const vector<double> &elementLatticeVectors) { - typedef array<double, DIM> point; - typedef array<double, DIM * DIM> matrix; + const std::vector<unsigned int> &nodeIDsAndMaterialIndices, + const std::vector<double> &nodeCoordinates, + const std::vector<unsigned int> &elementAndNodeIDs, + const std::vector<double> &elementLatticeVectors) { + typedef std::array<double, DIM> point; + typedef std::array<double, DIM * DIM> matrix; - vector<matrix> localBasisRead; + std::vector<matrix> localBasisRead; // assert(elementLatticeVectors.size() == noofLocalCells*DIM*DIM); if (elementLatticeVectors.size() == noofLocalCells * DIM * DIM) { @@ -32,9 +35,9 @@ void restart::rearrangeMeshFromRestart( // send the requested nodes point nodePoint; - unordered_set<unsigned int> localNodeIDsRead; - unordered_map<unsigned int, point> localPointsRead; - unordered_map<unsigned int, int> localMaterialIDsRead; + std::unordered_set<unsigned int> localNodeIDsRead; + std::unordered_map<unsigned int, point> localPointsRead; + std::unordered_map<unsigned int, int> localMaterialIDsRead; for (unsigned int i = 0; i < localNodesRead; i++) { localNodeIDsRead.insert(nodeIDsAndMaterialIndices[2 * i]); @@ -44,24 +47,24 @@ void restart::rearrangeMeshFromRestart( } localPointsRead.insert( - make_pair(nodeIDsAndMaterialIndices[2 * i], nodePoint)); + std::make_pair(nodeIDsAndMaterialIndices[2 * i], nodePoint)); localMaterialIDsRead.insert( - make_pair(nodeIDsAndMaterialIndices[2 * i], - static_cast<int>(nodeIDsAndMaterialIndices[2 * i + 1]))); + std::make_pair(nodeIDsAndMaterialIndices[2 * i], + static_cast<int>(nodeIDsAndMaterialIndices[2 * i + 1]))); } - unordered_set<unsigned int> elementNodeIDs; - unordered_map<unsigned int, point> elementNodePoints; - unordered_map<unsigned int, int> elementNodeMaterialIDs; + std::unordered_set<unsigned int> elementNodeIDs; + std::unordered_map<unsigned int, point> elementNodePoints; + std::unordered_map<unsigned int, int> elementNodeMaterialIDs; // assemble the nodes required from other processors - unordered_set<unsigned int> localNodeIDsInOtherProcs; + std::unordered_set<unsigned int> localNodeIDsInOtherProcs; int nodeKey; - array<size_t, mesh::SIMPLEX_DIMENSION_ + 1> indexedElement; + std::array<size_t, mesh::SIMPLEX_DIMENSION_ + 1> indexedElement; - vector<array<size_t, mesh::SIMPLEX_DIMENSION_ + 1>> elements; + std::vector<std::array<size_t, mesh::SIMPLEX_DIMENSION_ + 1>> elements; elements.reserve(noofLocalCells); for (unsigned int i = 0; i < noofLocalCells; i++) { @@ -77,10 +80,10 @@ void restart::rearrangeMeshFromRestart( (elementNodeIDs.find(nodeKey) == elementNodeIDs.end())) { elementNodeIDs.insert(nodeKey); elementNodePoints.insert( - make_pair(nodeKey, localPointsRead.at(nodeKey))); + std::make_pair(nodeKey, localPointsRead.at(nodeKey))); elementNodeMaterialIDs.insert( - make_pair(nodeKey, localMaterialIDsRead.at(nodeKey))); + std::make_pair(nodeKey, localMaterialIDsRead.at(nodeKey))); } if ((localNodeIDsRead.find(nodeKey) == localNodeIDsRead.end()) && @@ -93,23 +96,23 @@ void restart::rearrangeMeshFromRestart( elements.push_back(indexedElement); } - vector<unsigned int> localNodeIDsSend(localNodeIDsInOtherProcs.begin(), - localNodeIDsInOtherProcs.end()); + std::vector<unsigned int> localNodeIDsSend(localNodeIDsInOtherProcs.begin(), + localNodeIDsInOtherProcs.end()); // exchange nodes needed from others. do a gather. - vector<int> noofNodesFromAllProcsRecv(mpi_size, 0); + std::vector<int> noofNodesFromAllProcsRecv(mpi_size, 0); mpi_utilities::ALLGATHER1D<int>(localNodeIDsInOtherProcs.size(), noofNodesFromAllProcsRecv); - vector<int> nodeIDsDelimiters(mpi_size + 1, 0); + std::vector<int> nodeIDsDelimiters(mpi_size + 1, 0); for (int rank = 0; rank < mpi_size; rank++) { nodeIDsDelimiters[rank + 1] = nodeIDsDelimiters[rank] + noofNodesFromAllProcsRecv[rank]; } - vector<unsigned int> nodeIDsFromAllProcsRecv( + std::vector<unsigned int> nodeIDsFromAllProcsRecv( nodeIDsDelimiters[mpi_size - 1] + noofNodesFromAllProcsRecv[mpi_size - 1]); @@ -120,16 +123,16 @@ void restart::rearrangeMeshFromRestart( nodeIDsDelimiters.push_back(nodeIDsDelimiters[mpi_size - 1] + noofNodesFromAllProcsRecv[mpi_size - 1]); - vector<vector<unsigned int>> nodeIDsToSend(mpi_size); - vector<vector<int>> nodeMaterialIndicesToSend(mpi_size); - vector<vector<point>> nodePointsToSend(mpi_size); + std::vector<std::vector<unsigned int>> nodeIDsToSend(mpi_size); + std::vector<std::vector<int>> nodeMaterialIndicesToSend(mpi_size); + std::vector<std::vector<point>> nodePointsToSend(mpi_size); int nodeRank; - vector<int> noofNodalDataSend(mpi_size, 0); + std::vector<int> noofNodalDataSend(mpi_size, 0); for (int i = 0; i < nodeIDsFromAllProcsRecv.size(); i++) { - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(nodeIDsDelimiters.cbegin(), nodeIDsDelimiters.cend(), i); nodeRank = distance(nodeIDsDelimiters.cbegin(), it) - 1; @@ -149,14 +152,14 @@ void restart::rearrangeMeshFromRestart( } } - vector<int> noofNodalDataRecv(mpi_size); + std::vector<int> noofNodalDataRecv(mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<int>( noofNodalDataSend, noofNodalDataRecv, mpi_size); - vector<vector<unsigned int>> nodeIDsToRecv(mpi_size); - vector<vector<point>> nodePointsToRecv(mpi_size); - vector<vector<int>> nodeMaterialIndicesToRecv(mpi_size); + std::vector<std::vector<unsigned int>> nodeIDsToRecv(mpi_size); + std::vector<std::vector<point>> nodePointsToRecv(mpi_size); + std::vector<std::vector<int>> nodeMaterialIndicesToRecv(mpi_size); for (int rank = 0; rank < mpi_size; rank++) { nodeIDsToRecv[rank].resize(noofNodalDataRecv[rank]); @@ -178,19 +181,19 @@ void restart::rearrangeMeshFromRestart( elementNodeIDs.end()) { elementNodeIDs.insert(nodeIDsToRecv[rank][idx]); - elementNodePoints.insert( - make_pair(nodeIDsToRecv[rank][idx], nodePointsToRecv[rank][idx])); + elementNodePoints.insert(std::make_pair(nodeIDsToRecv[rank][idx], + nodePointsToRecv[rank][idx])); - elementNodeMaterialIDs.insert(make_pair( + elementNodeMaterialIDs.insert(std::make_pair( nodeIDsToRecv[rank][idx], nodeMaterialIndicesToRecv[rank][idx])); } } } } - vector<array<double, DIM>> nodes; - vector<size_t> nodeIDs; - vector<int> nodeMaterialIndices; + std::vector<std::array<double, DIM>> nodes; + std::vector<size_t> nodeIDs; + std::vector<int> nodeMaterialIndices; nodes.reserve(elementNodeIDs.size()); nodeIDs.reserve(elementNodeIDs.size()); @@ -232,24 +235,24 @@ template <typename mesh, int DIM> void restart::rearrangeMeshFromRestart( mesh &_local_mesh, const unsigned int &localNodesRead, const unsigned int &noofLocalCells, - const vector<unsigned int> &nodeIDsAndMaterialIndices, - const vector<double> &nodeCoordinates, + const std::vector<unsigned int> &nodeIDsAndMaterialIndices, + const std::vector<double> &nodeCoordinates, #ifdef FINITE_TEMPERATURE - const vector<double> &nodeThermalDOFs, + const std::vector<double> &nodeThermalDOFs, #endif - const vector<unsigned int> &elementAndNodeIDs, - const vector<double> &elementData) { + const std::vector<unsigned int> &elementAndNodeIDs, + const std::vector<double> &elementData) { - typedef array<double, DIM> point; - typedef array<double, mesh::THERMAL_DOFS_> thermalPoint; - typedef array<double, DIM * DIM> matrix; + typedef std::array<double, DIM> point; + typedef std::array<double, mesh::THERMAL_DOFS_> thermalPoint; + typedef std::array<double, DIM * DIM> matrix; - vector<matrix> localBasisRead(noofLocalCells); - vector<double> localDensitiesRead(noofLocalCells); - vector<double> localJacobiansRead(noofLocalCells); - vector<double> localElementWeightsRead(noofLocalCells); + std::vector<matrix> localBasisRead(noofLocalCells); + std::vector<double> localDensitiesRead(noofLocalCells); + std::vector<double> localJacobiansRead(noofLocalCells); + std::vector<double> localElementWeightsRead(noofLocalCells); - vector<int> localElementAtomisticFlagsRead(noofLocalCells); + std::vector<int> localElementAtomisticFlagsRead(noofLocalCells); for (unsigned int i = 0; i < noofLocalCells; i++) { @@ -272,16 +275,16 @@ void restart::rearrangeMeshFromRestart( // send the requested nodes point nodePoint; - unordered_set<unsigned int> localNodeIDsRead; - unordered_map<unsigned int, point> localPointsRead; - unordered_map<unsigned int, int> localMaterialIDsRead; + std::unordered_set<unsigned int> localNodeIDsRead; + std::unordered_map<unsigned int, point> localPointsRead; + std::unordered_map<unsigned int, int> localMaterialIDsRead; - unordered_map<unsigned int, double> localNodesWeightsRead; - unordered_map<unsigned int, int> localNodesFlagsRead; + std::unordered_map<unsigned int, double> localNodesWeightsRead; + std::unordered_map<unsigned int, int> localNodesFlagsRead; #ifdef FINITE_TEMPERATURE - unordered_map<unsigned int, thermalPoint> localThermalNodesRead; - unordered_map<unsigned int, double> localEntropiesRead; + std::unordered_map<unsigned int, thermalPoint> localThermalNodesRead; + std::unordered_map<unsigned int, double> localEntropiesRead; thermalPoint nodeThermalPoint; double nodeEntropy; #endif @@ -299,19 +302,19 @@ void restart::rearrangeMeshFromRestart( } localPointsRead.insert( - make_pair(nodeIDsAndMaterialIndices[3 * i], nodePoint)); + std::make_pair(nodeIDsAndMaterialIndices[3 * i], nodePoint)); localNodesWeightsRead.insert( - make_pair(nodeIDsAndMaterialIndices[3 * i], - nodeCoordinates[(DIM + 1) * i + DIM])); + std::make_pair(nodeIDsAndMaterialIndices[3 * i], + nodeCoordinates[(DIM + 1) * i + DIM])); - localMaterialIDsRead.insert( - make_pair(nodeIDsAndMaterialIndices[3 * i], - static_cast<int>(nodeIDsAndMaterialIndices[3 * i + 1]))); + localMaterialIDsRead.insert(std::make_pair( + nodeIDsAndMaterialIndices[3 * i], + static_cast<int>(nodeIDsAndMaterialIndices[3 * i + 1]))); - localNodesFlagsRead.insert( - make_pair(nodeIDsAndMaterialIndices[3 * i], - static_cast<int>(nodeIDsAndMaterialIndices[3 * i + 2]))); + localNodesFlagsRead.insert(std::make_pair( + nodeIDsAndMaterialIndices[3 * i], + static_cast<int>(nodeIDsAndMaterialIndices[3 * i + 2]))); #ifdef FINITE_TEMPERATURE @@ -324,33 +327,33 @@ void restart::rearrangeMeshFromRestart( nodeThermalDOFs[(mesh::THERMAL_DOFS_ + 1) * i + mesh::THERMAL_DOFS_]; localThermalNodesRead.insert( - make_pair(nodeIDsAndMaterialIndices[3 * i], nodeThermalPoint)); + std::make_pair(nodeIDsAndMaterialIndices[3 * i], nodeThermalPoint)); localEntropiesRead.insert( - make_pair(nodeIDsAndMaterialIndices[3 * i], nodeEntropy)); + std::make_pair(nodeIDsAndMaterialIndices[3 * i], nodeEntropy)); #endif } } - unordered_set<unsigned int> elementNodeIDs; - unordered_map<unsigned int, point> elementNodePoints; - unordered_map<unsigned int, int> elementNodeMaterialIDs; + std::unordered_set<unsigned int> elementNodeIDs; + std::unordered_map<unsigned int, point> elementNodePoints; + std::unordered_map<unsigned int, int> elementNodeMaterialIDs; - unordered_map<size_t, double> elementNodeWeights; - unordered_map<size_t, int> elementNodeFlags; + std::unordered_map<size_t, double> elementNodeWeights; + std::unordered_map<size_t, int> elementNodeFlags; #ifdef FINITE_TEMPERATURE - unordered_map<size_t, thermalPoint> elementNodeThermalPoints; - unordered_map<size_t, double> elementNodeEntropies; + std::unordered_map<size_t, thermalPoint> elementNodeThermalPoints; + std::unordered_map<size_t, double> elementNodeEntropies; #endif // assemble the nodes required from other processors - unordered_set<unsigned int> localNodeIDsInOtherProcs; + std::unordered_set<unsigned int> localNodeIDsInOtherProcs; int nodeKey; - array<size_t, mesh::SIMPLEX_DIMENSION_ + 1> indexedElement; + std::array<size_t, mesh::SIMPLEX_DIMENSION_ + 1> indexedElement; - vector<array<size_t, mesh::SIMPLEX_DIMENSION_ + 1>> elements; + std::vector<std::array<size_t, mesh::SIMPLEX_DIMENSION_ + 1>> elements; elements.reserve(noofLocalCells); for (unsigned int i = 0; i < noofLocalCells; i++) { @@ -366,23 +369,23 @@ void restart::rearrangeMeshFromRestart( (elementNodeIDs.find(nodeKey) == elementNodeIDs.end())) { elementNodeIDs.insert(nodeKey); elementNodePoints.insert( - make_pair(nodeKey, localPointsRead.at(nodeKey))); + std::make_pair(nodeKey, localPointsRead.at(nodeKey))); elementNodeMaterialIDs.insert( - make_pair(nodeKey, localMaterialIDsRead.at(nodeKey))); + std::make_pair(nodeKey, localMaterialIDsRead.at(nodeKey))); - elementNodeWeights.insert(make_pair(static_cast<size_t>(nodeKey), - localNodesWeightsRead.at(nodeKey))); + elementNodeWeights.insert(std::make_pair( + static_cast<size_t>(nodeKey), localNodesWeightsRead.at(nodeKey))); - elementNodeFlags.insert(make_pair(static_cast<size_t>(nodeKey), - localNodesFlagsRead.at(nodeKey))); + elementNodeFlags.insert(std::make_pair( + static_cast<size_t>(nodeKey), localNodesFlagsRead.at(nodeKey))); #ifdef FINITE_TEMPERATURE - elementNodeThermalPoints.insert(make_pair( + elementNodeThermalPoints.insert(std::make_pair( static_cast<size_t>(nodeKey), localThermalNodesRead.at(nodeKey))); - elementNodeEntropies.insert(make_pair(static_cast<size_t>(nodeKey), - localEntropiesRead.at(nodeKey))); + elementNodeEntropies.insert(std::make_pair( + static_cast<size_t>(nodeKey), localEntropiesRead.at(nodeKey))); #endif } @@ -396,24 +399,24 @@ void restart::rearrangeMeshFromRestart( elements.push_back(indexedElement); } - vector<unsigned int> localNodeIDsSend(localNodeIDsInOtherProcs.begin(), - localNodeIDsInOtherProcs.end()); + std::vector<unsigned int> localNodeIDsSend(localNodeIDsInOtherProcs.begin(), + localNodeIDsInOtherProcs.end()); // exchange nodes needed from others. do a gather. - vector<int> noofNodesFromAllProcsRecv(mpi_size, 0); + std::vector<int> noofNodesFromAllProcsRecv(mpi_size, 0); // all-gather amount of interproc balls-data to exchange mpi_utilities::ALLGATHER1D<int>(localNodeIDsInOtherProcs.size(), noofNodesFromAllProcsRecv); - vector<int> nodeIDsDelimiters(mpi_size + 1, 0); + std::vector<int> nodeIDsDelimiters(mpi_size + 1, 0); for (int rank = 0; rank < mpi_size; rank++) { nodeIDsDelimiters[rank + 1] = nodeIDsDelimiters[rank] + noofNodesFromAllProcsRecv[rank]; } - vector<unsigned int> nodeIDsFromAllProcsRecv( + std::vector<unsigned int> nodeIDsFromAllProcsRecv( nodeIDsDelimiters[mpi_size - 1] + noofNodesFromAllProcsRecv[mpi_size - 1]); @@ -424,24 +427,24 @@ void restart::rearrangeMeshFromRestart( nodeIDsDelimiters.push_back(nodeIDsDelimiters[mpi_size - 1] + noofNodesFromAllProcsRecv[mpi_size - 1]); - vector<vector<unsigned int>> nodeIDsToSend(mpi_size); - vector<vector<int>> nodeMaterialIndicesToSend(mpi_size); - vector<vector<point>> nodePointsToSend(mpi_size); + std::vector<std::vector<unsigned int>> nodeIDsToSend(mpi_size); + std::vector<std::vector<int>> nodeMaterialIndicesToSend(mpi_size); + std::vector<std::vector<point>> nodePointsToSend(mpi_size); - vector<vector<double>> nodeWeightsToSend(mpi_size); - vector<vector<int>> nodeFlagsToSend(mpi_size); + std::vector<std::vector<double>> nodeWeightsToSend(mpi_size); + std::vector<std::vector<int>> nodeFlagsToSend(mpi_size); #ifdef FINITE_TEMPERATURE - vector<vector<thermalPoint>> nodeThermalPointsToSend(mpi_size); - vector<vector<double>> nodeEntropiesToSend(mpi_size); + std::vector<std::vector<thermalPoint>> nodeThermalPointsToSend(mpi_size); + std::vector<std::vector<double>> nodeEntropiesToSend(mpi_size); #endif int nodeRank; - vector<int> noofNodalDataSend(mpi_size, 0); + std::vector<int> noofNodalDataSend(mpi_size, 0); for (int i = 0; i < nodeIDsFromAllProcsRecv.size(); i++) { - const vector<int>::const_iterator it = + const std::vector<int>::const_iterator it = upper_bound(nodeIDsDelimiters.cbegin(), nodeIDsDelimiters.cend(), i); nodeRank = distance(nodeIDsDelimiters.cbegin(), it) - 1; @@ -475,21 +478,21 @@ void restart::rearrangeMeshFromRestart( } } - vector<int> noofNodalDataRecv(mpi_size); + std::vector<int> noofNodalDataRecv(mpi_size); mpi_utilities::MPIExchangeBuffers_NonBlocking<int>( noofNodalDataSend, noofNodalDataRecv, mpi_size); - vector<vector<unsigned int>> nodeIDsToRecv(mpi_size); - vector<vector<point>> nodePointsToRecv(mpi_size); - vector<vector<int>> nodeMaterialIndicesToRecv(mpi_size); + std::vector<std::vector<unsigned int>> nodeIDsToRecv(mpi_size); + std::vector<std::vector<point>> nodePointsToRecv(mpi_size); + std::vector<std::vector<int>> nodeMaterialIndicesToRecv(mpi_size); - vector<vector<double>> nodeWeightsToRecv(mpi_size); - vector<vector<int>> nodeFlagsToRecv(mpi_size); + std::vector<std::vector<double>> nodeWeightsToRecv(mpi_size); + std::vector<std::vector<int>> nodeFlagsToRecv(mpi_size); #ifdef FINITE_TEMPERATURE - vector<vector<thermalPoint>> nodeThermalPointsToRecv(mpi_size); - vector<vector<double>> nodeEntropiesToRecv(mpi_size); + std::vector<std::vector<thermalPoint>> nodeThermalPointsToRecv(mpi_size); + std::vector<std::vector<double>> nodeEntropiesToRecv(mpi_size); #endif for (int rank = 0; rank < mpi_size; rank++) { @@ -533,37 +536,37 @@ void restart::rearrangeMeshFromRestart( elementNodeIDs.end()) { elementNodeIDs.insert(nodeIDsToRecv[rank][idx]); - elementNodePoints.insert( - make_pair(nodeIDsToRecv[rank][idx], nodePointsToRecv[rank][idx])); + elementNodePoints.insert(std::make_pair(nodeIDsToRecv[rank][idx], + nodePointsToRecv[rank][idx])); - elementNodeMaterialIDs.insert(make_pair( + elementNodeMaterialIDs.insert(std::make_pair( nodeIDsToRecv[rank][idx], nodeMaterialIndicesToRecv[rank][idx])); elementNodeWeights.insert( - make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), - nodeWeightsToRecv[rank][idx])); + std::make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), + nodeWeightsToRecv[rank][idx])); elementNodeFlags.insert( - make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), - nodeFlagsToRecv[rank][idx])); + std::make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), + nodeFlagsToRecv[rank][idx])); #ifdef FINITE_TEMPERATURE elementNodeThermalPoints.insert( - make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), - nodeThermalPointsToRecv[rank][idx])); + std::make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), + nodeThermalPointsToRecv[rank][idx])); elementNodeEntropies.insert( - make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), - nodeEntropiesToRecv[rank][idx])); + std::make_pair(static_cast<size_t>(nodeIDsToRecv[rank][idx]), + nodeEntropiesToRecv[rank][idx])); #endif } } } } - vector<array<double, DIM>> nodes; - vector<size_t> nodeIDs; - vector<int> nodeMaterialIndices; + std::vector<std::array<double, DIM>> nodes; + std::vector<size_t> nodeIDs; + std::vector<int> nodeMaterialIndices; nodes.reserve(elementNodeIDs.size()); nodeIDs.reserve(elementNodeIDs.size()); @@ -616,4 +619,4 @@ void restart::rearrangeMeshFromRestart( _local_mesh.initializeElementsAtomisticFlag(localElementAtomisticFlagsRead); _local_mesh.updateElements(); -} \ No newline at end of file +} diff --git a/src/preStrain/LomerDipole.ipp b/src/preStrain/LomerDipole.ipp index a409d431a..87d0953f6 100644 --- a/src/preStrain/LomerDipole.ipp +++ b/src/preStrain/LomerDipole.ipp @@ -1,8 +1,5 @@ #pragma once -using namespace std; -using namespace geometry; - template <typename Container> void ExternalDisplacement(Container &_points, const bool &_constrain, const point<3> &_upper, const point<3> &_lower) { @@ -31,12 +28,12 @@ void ExternalDisplacement(Container &_points, const bool &_constrain, r = x * x + y * y; u = (burgerV * - (atan2(y, x) + y * x / (f1 * r + numeric_limits<float>::min())) / + (atan2(y, x) + y * x / (f1 * r + std::numeric_limits<float>::min())) / (2.0 * PI)); v = -1.0 * burgerV * - (f2 * log(r + numeric_limits<float>::min()) + - (x * x - y * y) / (2.0 * f1 * r + numeric_limits<float>::min())) / + (f2 * log(r + std::numeric_limits<float>::min()) + + (x * x - y * y) / (2.0 * f1 * r + std::numeric_limits<float>::min())) / (2.0 * PI); // v = burgerV*(-1.0*f2*log(r/(burgerV*burgerV) + numeric_limits<float>::min() ) + @@ -47,13 +44,14 @@ void ExternalDisplacement(Container &_points, const bool &_constrain, y = l[1]; r = x * x + y * y; u2 = (-1.0 * burgerV * - (atan2(y, x) + y * x / (f1 * r + numeric_limits<float>::min())) / + (atan2(y, x) + y * x / (f1 * r + std::numeric_limits<float>::min())) / (2.0 * PI)); - v2 = -1.0 * (-1.0 * burgerV) * - (f2 * log(r + numeric_limits<float>::min()) + - (x * x - y * y) / (2.0 * f1 * r + numeric_limits<float>::min())) / - (2.0 * PI); + v2 = + -1.0 * (-1.0 * burgerV) * + (f2 * log(r + std::numeric_limits<float>::min()) + + (x * x - y * y) / (2.0 * f1 * r + std::numeric_limits<float>::min())) / + (2.0 * PI); // v2 = (-1.0*burgerV)*(-1.0*f2*log(r/(burgerV*burgerV) // + numeric_limits<float>::min() ) + diff --git a/src/preprocessor/preproc.h b/src/preprocessor/preproc.h index 23c83cf74..c2de28b16 100644 --- a/src/preprocessor/preproc.h +++ b/src/preprocessor/preproc.h @@ -1,3 +1,4 @@ +#pragma once #include "StandardHeaders.h" #include "mpi_var.h" #include "variables.h" @@ -23,7 +24,7 @@ using test = std::function<void(int &)>; template <int DIM> using LatticeGenerator = std::function<void(std::vector<geometry::point<DIM>> &, std::vector<int> &, - Box<point<DIM>, DIM> &, string &, + Box<point<DIM>, DIM> &, std::string &, Box<point<DIM>, DIM> &_domains, int &, const std::array<std::array<double, DIM>, DIM> &_basis)>; @@ -37,22 +38,22 @@ namespace preproc { // mesh generator can read from file or generate from lattice template <typename GlobalMesh, typename LocalMesh, int DIM> -string generateLatticeAndSaveMesh( +std::string generateLatticeAndSaveMesh( const LatticeGenerator<DIM> &generateLattice, const MeshGenerator<GlobalMesh, LocalMesh, DIM> &generateMesh, - const vector<material<DIM> *> &_materials) { + const std::vector<material<DIM> *> &_materials) { // lattice generator can either read from file or create vectors, // call lattice generator and triangulators only from rank = 0 Box<point<DIM>, DIM> domain_bounds; - vector<point<DIM>> lattice; - vector<int> materialIDs; + std::vector<point<DIM>> lattice; + std::vector<int> materialIDs; GlobalMesh global_mesh; LocalMesh local_mesh; int outputNameLength; int saveLatticeVectors; - string outputFileName; + std::string outputFileName; Box<point<DIM>, DIM> atomistic_domain; @@ -81,15 +82,15 @@ string generateLatticeAndSaveMesh( atomistic_domain.lower_ = atomistic_domain_lower; } - mpi_utilities::boostBroadcast<string>(outputFileName); + mpi_utilities::boostBroadcast<std::string>(outputFileName); mpi_utilities::BCAST<double, DIM>(domain_bounds.upper_, 0); mpi_utilities::BCAST<double, DIM>(domain_bounds.lower_, 0); - mpi_utilities::boostBroadcast<vector<int>>(materialIDs); + mpi_utilities::boostBroadcast<std::vector<int>>(materialIDs); generateMesh(lattice, materialIDs, _materials, domain_bounds, atomistic_domain, global_mesh, local_mesh); - string outDir = "./meshFiles/"; + std::string outDir = "./meshFiles/"; // save mesh .nc file and .pvtu file for visualization if (DIM == 3) { if (mpi_rank == 0) { diff --git a/src/solver/calculateDeformation.ipp b/src/solver/calculateDeformation.ipp index 59acd6650..7ce28c8f7 100644 --- a/src/solver/calculateDeformation.ipp +++ b/src/solver/calculateDeformation.ipp @@ -1,15 +1,14 @@ #pragma once - -using namespace std; +#include "solver.h" template <typename mesh_d, int DIM> void solver::deformMeshElements(mesh_d &_mesh) { - typedef array<double, DIM> Point; + typedef std::array<double, DIM> Point; typedef Eigen::Matrix<double, DIM, DIM> Matrix; - typedef array<Point, DIM + 1> Simplex; + typedef std::array<Point, DIM + 1> Simplex; - array<Point, DIM> deformed_edges; - array<Point, DIM> undeformed_edges; + std::array<Point, DIM> deformed_edges; + std::array<Point, DIM> undeformed_edges; Simplex simplex; Matrix F; @@ -22,8 +21,8 @@ void solver::deformMeshElements(mesh_d &_mesh) { // volume element, and then return with a message to // remesh/refine size_t cellKey, nodeIndex, nodeKey; - array<size_t, DIM + 1> indexedSimplex; - vector<size_t> elementsToCompress; + std::array<size_t, DIM + 1> indexedSimplex; + std::vector<size_t> elementsToCompress; double J; elementsToCompress.reserve(int(_mesh.meshCells_.size() / 10)); @@ -83,9 +82,9 @@ void solver::deformMeshElements(mesh_d &_mesh) { _mesh.element_qualities_[i_el] = simplexMetricResidual<DIM>(deformed_edges); } - // array<double, 3> u, v, w; + // std::array<double, 3> u, v, w; - // vector<size_t> showElements = {16, 34001, 39565}; + // std::vector<size_t> showElements = {16, 34001, 39565}; // for(size_t i_el : showElements) // { // cellKey = _mesh.simplex_index_to_key_[i_el]; @@ -105,8 +104,8 @@ void solver::deformMeshElements(mesh_d &_mesh) { // cout<<"lattice vectors "<<_mesh.element_lattice_vectors_[i_el]<<endl; // } - // vector<Point> correctedDisplacements; - // vector<size_t> correctedNodeIDs; + // std::vector<Point> correctedDisplacements; + // std::vector<size_t> correctedNodeIDs; // int d; // size_t cellIndex; @@ -131,8 +130,8 @@ void solver::deformMeshElements(mesh_d &_mesh) { // // sent by multiple processors, then we clearly have two neighbouring // // inverted elements. This shouldn't happen. - // vector<size_t> displacedNodeKeysAllProcs; - // vector<Point> displacementsAllProcs; + // std::vector<size_t> displacedNodeKeysAllProcs; + // std::vector<Point> displacementsAllProcs; // for(size_t i_el=0; i_el<_mesh.simplices_.size(); i_el++) // { @@ -209,16 +208,16 @@ void solver::deformMeshOverlaps(mesh_d &_local_mesh) { template <typename InputClass, typename mesh, int DIM, int NIDOF> void solver::deformSamplingAtomsAndNeighbourhoods( const InputClass &_inputParams, mesh &_local_mesh, - vector<size_t> &_highly_deformed_nodal_sampling_atoms, - vector<size_t> &_highly_deformed_cb_sampling_atoms, - vector<size_t> &_meshExchange_nodal_sampling_atoms, - vector<size_t> &_periodicExchange_nodal_sampling_atoms) { + std::vector<size_t> &_highly_deformed_nodal_sampling_atoms, + std::vector<size_t> &_highly_deformed_cb_sampling_atoms, + std::vector<size_t> &_meshExchange_nodal_sampling_atoms, + std::vector<size_t> &_periodicExchange_nodal_sampling_atoms) { #ifdef MULTI_THREADING -#pragma omp declare reduction (merge : std::vector<size_t> : \ +#pragma omp declare reduction (merge : std::std::vector<size_t> : \ omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end())) -#pragma omp declare reduction(vec_int_plus : std::vector<int> : \ +#pragma omp declare reduction(vec_int_plus : std::std::vector<int> : \ std::transform(omp_out.begin(), omp_out.end(), \ omp_in.begin(), omp_out.begin(), std::plus<int>())) \ initializer(omp_priv = decltype(omp_orig)(omp_orig.size())) @@ -226,13 +225,13 @@ void solver::deformSamplingAtomsAndNeighbourhoods( // after this, all nodal sampling atoms have their own // neighbours and their own temperatures correctly updated typedef lattice::latticeSite<DIM, NIDOF> neighbour_site; - typedef typename vector<neighbour_site>::iterator neighbourIt; + typedef typename std::vector<neighbour_site>::iterator neighbourIt; point<DIM> sampling_atom_location; point<DIM> neighbour_location; - vector<int> samplingAtomRequiringOverlapRebuild(_local_mesh.meshNodes_.size(), - 0); + std::vector<int> samplingAtomRequiringOverlapRebuild( + _local_mesh.meshNodes_.size(), 0); double dx_nei, dx_nei_max, dx_nei_max_2, dx_samplingAtom; @@ -247,8 +246,8 @@ void solver::deformSamplingAtomsAndNeighbourhoods( #endif { #ifdef FINITE_TEMPERATURE - array<double, NIDOF> sampling_atom_thermal_coordinate; - array<double, NIDOF> neighbour_thermal_coordinate; + std::array<double, NIDOF> sampling_atom_thermal_coordinate; + std::array<double, NIDOF> neighbour_thermal_coordinate; #endif #ifdef MULTI_THREADING @@ -439,15 +438,15 @@ void solver::deformSamplingAtomsAndNeighbourhoods( size_t elementKeyCentralAtom; - array<point<DIM>, DIM + 1> simplex; - array<size_t, DIM + 1> indexedSimplex; + std::array<point<DIM>, DIM + 1> simplex; + std::array<size_t, DIM + 1> indexedSimplex; // #pragma omp parallel default(shared) \ // private(Barycenter, simplex, i_el) { #ifdef FINITE_TEMPERATURE - array<double, NIDOF> sampling_atom_thermal_coordinate; - array<double, NIDOF> neighbour_thermal_coordinate; + std::array<double, NIDOF> sampling_atom_thermal_coordinate; + std::array<double, NIDOF> neighbour_thermal_coordinate; #endif // #pragma omp for schedule(static) diff --git a/src/solver/initializer.h b/src/solver/initializer.h index 0c0b002aa..6d2784936 100644 --- a/src/solver/initializer.h +++ b/src/solver/initializer.h @@ -14,7 +14,6 @@ #include "repatoms.h" #include "samplingatoms.h" -// #include "neighbourhoods.h" #include "boundaryconditions.h" #include "solver.h" @@ -23,15 +22,13 @@ #include "pnetIO.h" #include "vtkIO.h" -using namespace std; - namespace initializer { template <typename point_d, typename qc_mesh_d, typename input, typename lattice_d, typename box_d, int DIM, int NIDOF> void InitializeMesh(qc_mesh_d &_local_mesh, box_d &_domain_bounds, - const vector<material<DIM> *> &_materials, + const std::vector<material<DIM> *> &_materials, const input &_inputParams) { - vector<int> node_material_idxs; + std::vector<int> node_material_idxs; if (!read_restart) { bool reassign_lattice_vectors; @@ -57,10 +54,10 @@ void InitializeMesh(qc_mesh_d &_local_mesh, box_d &_domain_bounds, // build repatom locations and sampling atom locations. if (!read_restart) { - unordered_map<size_t, int> initialFixedFlags; + std::unordered_map<size_t, int> initialFixedFlags; for (size_t i_nd = 0; i_nd < _local_mesh.meshNodes_.size(); i_nd++) { initialFixedFlags.insert( - make_pair(_local_mesh.node_index_to_key_[i_nd], false)); + std::make_pair(_local_mesh.node_index_to_key_[i_nd], false)); } #ifdef FINITE_TEMPERATURE @@ -94,13 +91,13 @@ void InitializeMesh(qc_mesh_d &_local_mesh, box_d &_domain_bounds, thermalPoint[1] = _inputParams.Phi_ref_i; initialThermalConditions.insert( - make_pair(_local_mesh.node_index_to_key_[i_nd], thermalPoint)); + std::make_pair(_local_mesh.node_index_to_key_[i_nd], thermalPoint)); // S = (3kB/2)\ln(\Omega\Sigma) + S_0(const.) entropy = -1.5 * k_Boltzmann * (thermalPoint[0] + thermalPoint[1]); initialEntropies.insert( - make_pair(_local_mesh.node_index_to_key_[i_nd], entropy)); + std::make_pair(_local_mesh.node_index_to_key_[i_nd], entropy)); } #endif @@ -142,9 +139,9 @@ void InitializeMesh(qc_mesh_d &_local_mesh, box_d &_domain_bounds, box_d local_domain; - bindBox< - Box<point<DIM>, DIM>, typename vector<point<DIM>>::iterator, - DerefPointIterator<typename vector<point<DIM>>::iterator, point<DIM>>>( + bindBox<Box<point<DIM>, DIM>, typename std::vector<point<DIM>>::iterator, + DerefPointIterator<typename std::vector<point<DIM>>::iterator, + point<DIM>>>( _local_mesh.repatoms.locations_.begin(), _local_mesh.repatoms.locations_.end(), local_domain); @@ -193,7 +190,7 @@ void InitializeExternalApplicator(const userInput &_input, indenter_center[DIM - 1] = _input.indenter_radius_i + _input.initial_offset_i; if (_input.intialize_force_applicator_i) { - string forceApplicatorName; + std::string forceApplicatorName; if (read_restart && restartfile_iter > 2) { restart::ReadExternalForceApplicator<DIM>( forceApplicatorName, indenter_center, radius, force_constant, @@ -202,7 +199,8 @@ void InitializeExternalApplicator(const userInput &_input, forceApplicatorName = "indenter: sphere"; } - indenter_increment = max(indenter_increment, _input.indenter_increment_i); + indenter_increment = + std::max(indenter_increment, _input.indenter_increment_i); if (strcmp(forceApplicatorName.c_str(), "indenter: sphere") == 0) { _external_applicator = new nanoindenter_sphere<DIM>( @@ -225,12 +223,12 @@ void InitializePeriodicLengths(const int &_n_periods, periodLengths[d][1] = _domain_bounds.upper_[d]; } - array<int, 3> offsetOrder = {{0, 1, -1}}; + std::array<int, 3> offsetOrder = {{0, 1, -1}}; int noofAllOffsets = int(pow(3, _n_periods)); // build allPeriodicOffsetDirections allPeriodicOffsetDirections.resize(noofAllOffsets, - filled_array<array<int, 3>>(0)); + std::filled_array<std::array<int, 3>>(0)); periodicSimulationFlag = false; if (_n_periods == 1) { diff --git a/src/solver/petscSolver.ipp b/src/solver/petscSolver.ipp index 26fbd9118..817cdbe60 100644 --- a/src/solver/petscSolver.ipp +++ b/src/solver/petscSolver.ipp @@ -1,4 +1,5 @@ #pragma once +#include "solver.h" namespace solver { void Solver::wrapPetscVecToRepatoms() { diff --git a/src/solver/solver.h b/src/solver/solver.h index a375b93f0..e3f2d0639 100644 --- a/src/solver/solver.h +++ b/src/solver/solver.h @@ -18,13 +18,12 @@ #include "lattice.h" #include "materials.h" #include "neighbourhoods.h" +#include "pnetIO.h" #include "qcMesh.h" #include "repatomcontainer.h" #include "repatoms.h" #include "samplingatoms.h" #include "utilities.h" - -#include "pnetIO.h" #include "vtkIO.h" #include "userinput.h" @@ -33,16 +32,14 @@ // #include "debuggers.h" #endif -using namespace std; -using namespace geometry; - namespace solver { template <typename mesh, typename boundary_condition, typename box> void VelocityVerletFIRE(mesh &, const bool &, const bool &, - vector<boundary_condition *> &, bool &); + std::vector<boundary_condition *> &, bool &); template <typename repatom, typename boundary_condition> -void VelocityVerlet(vector<repatom> &, vector<boundary_condition *> &); +void VelocityVerlet(std::vector<repatom> &, + std::vector<boundary_condition *> &); template <typename mesh, int DIM> void deformMeshElements(mesh &_mesh); @@ -51,47 +48,49 @@ template <typename mesh, int DIM, int NIDOF> void deformMeshOverlaps(mesh &); template <typename InputClass, typename mesh, int DIM, int NIDOF> void deformSamplingAtomsAndNeighbourhoods( const InputClass &_inputParams, mesh &_local_mesh, - vector<size_t> &_highly_deformed_nodal_sampling_atoms, - vector<size_t> &_highly_deformed_cb_sampling_atoms, - vector<size_t> &_meshExchange_nodal_sampling_atoms, - vector<size_t> &_periodicExchange_nodal_sampling_atoms); + std::vector<size_t> &_highly_deformed_nodal_sampling_atoms, + std::vector<size_t> &_highly_deformed_cb_sampling_atoms, + std::vector<size_t> &_meshExchange_nodal_sampling_atoms, + std::vector<size_t> &_periodicExchange_nodal_sampling_atoms); template <typename mesh, typename sampling_atom, typename repatomContainer, typename boundary_condition, typename external_force_applicator, typename sampling_atomIt> -void relaxAtomLocations(repatomContainer &, vector<sampling_atom> &, - vector<sampling_atom> &, vector<sampling_atomIt> &, - mesh &, vector<boundary_condition *> &, +void relaxAtomLocations(repatomContainer &, std::vector<sampling_atom> &, + std::vector<sampling_atom> &, + std::vector<sampling_atomIt> &, mesh &, + std::vector<boundary_condition *> &, external_force_applicator &, - const vector<material<DIM> *> &, Box<point<DIM>, DIM> &, - bool, const bool &); + const std::vector<material<DIM> *> &, + Box<point<DIM>, DIM> &, bool, const bool &); template <typename mesh, typename sampling_atom, typename repatomContainer, typename boundary_condition, typename external_force_applicator, int DIM> void relaxAtomsPetsc(repatomContainer &_local_repatom_container, - vector<sampling_atom> &, vector<sampling_atom> &, mesh &, - vector<boundary_condition *> &, + std::vector<sampling_atom> &, std::vector<sampling_atom> &, + mesh &, std::vector<boundary_condition *> &, external_force_applicator &, - const vector<material<DIM> *> &, Box<point<DIM>, DIM> &, - bool, const bool &); + const std::vector<material<DIM> *> &, + Box<point<DIM>, DIM> &, bool, const bool &); template <typename mesh, typename sampling_atom, typename repatomContainer, typename boundary_condition, typename external_force_applicator, int DIM> -void driver(repatomContainer &, vector<sampling_atom> &, - vector<sampling_atom> &, mesh &, vector<boundary_condition *> &, - external_force_applicator &, const vector<material<DIM> *> &, - Box<point<DIM>, DIM> &); +void driver(repatomContainer &, std::vector<sampling_atom> &, + std::vector<sampling_atom> &, mesh &, + std::vector<boundary_condition *> &, external_force_applicator &, + const std::vector<material<DIM> *> &, Box<point<DIM>, DIM> &); template <typename mesh, typename sampling_atom, typename repatomContainer, typename boundary_condition, typename external_force_applicator, int DIM> -void thermalExpansion(repatomContainer &, vector<sampling_atom> &, - vector<sampling_atom> &, mesh &, - vector<boundary_condition *> &, +void thermalExpansion(repatomContainer &, std::vector<sampling_atom> &, + std::vector<sampling_atom> &, mesh &, + std::vector<boundary_condition *> &, external_force_applicator &, - const vector<material<DIM> *> &, Box<point<DIM>, DIM> &); + const std::vector<material<DIM> *> &, + Box<point<DIM>, DIM> &); // template<typename mesh, // typename samplingAtom, @@ -114,10 +113,10 @@ public: typedef ExternalForceApplicator<DIM> externalForceApplicator; public: - typedef typename vector<point<DIM>>::iterator pointIt; + typedef typename std::vector<point<DIM>>::iterator pointIt; typedef DerefPointIterator<pointIt, point<DIM>> pointLocator; typedef Box<point<DIM>, DIM> box; - typedef typename vector<samplingAtom>::iterator samplingAtomIt; + typedef typename std::vector<samplingAtom>::iterator samplingAtomIt; typedef output::VTKWriter<DIM, mesh, repatomContainer, externalForceApplicator, boundaryCondition, @@ -158,13 +157,13 @@ public: static mesh local_mesh_; // ! REMOVE (sampling atoms and repatoms are within local mesh now) - static vector<samplingAtom> local_nodal_sampling_atoms_; - static vector<samplingAtom> local_cb_sampling_atoms_; + static std::vector<samplingAtom> local_nodal_sampling_atoms_; + static std::vector<samplingAtom> local_cb_sampling_atoms_; static repatomContainer localRepatomContainer_; - static vector<boundaryCondition *> boundary_conditions_; + static std::vector<boundaryCondition *> boundary_conditions_; static externalForceApplicator *external_force_applicator_; - static vector<material<DIM> *> materials_; + static std::vector<material<DIM> *> materials_; static VTKWriter repatom_writer_; @@ -174,14 +173,14 @@ public: static int nVar_; static int global_neighbours_regenerated_; - static vector<size_t> triggered_nodal_sampling_atoms_; - static vector<size_t> triggered_cb_sampling_atoms_; - static vector<size_t> triggered_meshExchange_sampling_atoms_; - static vector<size_t> triggered_periodicMeshExchange_sampling_atoms_; + static std::vector<size_t> triggered_nodal_sampling_atoms_; + static std::vector<size_t> triggered_cb_sampling_atoms_; + static std::vector<size_t> triggered_meshExchange_sampling_atoms_; + static std::vector<size_t> triggered_periodicMeshExchange_sampling_atoms_; // ! REMOVE - static vector<samplingAtomIt> triggered_nodal_sampling_atoms_OLD; - static vector<samplingAtomIt> triggered_cb_sampling_atoms_OLD; + static std::vector<samplingAtomIt> triggered_nodal_sampling_atoms_OLD; + static std::vector<samplingAtomIt> triggered_cb_sampling_atoms_OLD; // petsc variables/settings public: @@ -257,7 +256,8 @@ public: #endif } - static void updateBoundaryConstraints(const vector<string> &_types) { + static void + updateBoundaryConstraints(const std::vector<std::string> &_types) { // update the domain bounds bindBox<box, pointIt, pointLocator>(local_mesh_.repatoms.locations_.begin(), local_mesh_.repatoms.locations_.end(), @@ -339,10 +339,11 @@ public: } } - static void updateBoundaryConstraints(const vector<string> &_types, - const vector<double> &_bounds, - const vector<int> &_coordinates, - const vector<point<DIM>> &_normals) { + static void + updateBoundaryConstraints(const std::vector<std::string> &_types, + const std::vector<double> &_bounds, + const std::vector<int> &_coordinates, + const std::vector<point<DIM>> &_normals) { boundary_conditions_.clear(); boundary_conditions_.resize(N_zones); @@ -805,7 +806,7 @@ public: } #ifdef FINITE_TEMPERATURE - static void exchangeInterprocScalars(vector<double> &_scalars) { + static void exchangeInterprocScalars(std::vector<double> &_scalars) { // transfer entropy rates from repatoms to sDot_distributed_ VecGhostGetLocalForm(sDot_distributed_, &sDot_local_); VecGetArray(sDot_local_, &local_sDot_array); diff --git a/src/solver/timeIntegrators.ipp b/src/solver/timeIntegrators.ipp index db83d2b5f..37ce0d5df 100644 --- a/src/solver/timeIntegrators.ipp +++ b/src/solver/timeIntegrators.ipp @@ -1,27 +1,28 @@ #pragma once - -using namespace std; +#include "solver.h" template <typename repatom, typename boundary_condition> void solver::VelocityVerlet( - vector<repatom> &_repatoms, - vector<boundary_condition *> &_boundary_conditions) { + std::vector<repatom> &_repatoms, + std::vector<boundary_condition *> &_boundary_conditions) { size_t repatom_ctr = 0; for (repatom &atom : _repatoms) { #ifdef CHECK_FOR_NAN if (std::isnan(magnitude(atom.force_))) { - cout << "rank " << mpi_rank - << " detected NaN force on a repatom. Repatom id " << repatom_ctr - << " , current location : " << atom.location_ << " , " << atom.mass_ - << endl; + std::cout << "rank " << mpi_rank + << " detected NaN force on a repatom. Repatom id " + << repatom_ctr << " , current location : " << atom.location_ + << " , " << atom.mass_ << std::endl; #ifdef DEBUG_INTERPROC_NEIGHBOURS for (int i_bond = 0; i_bond < atom.candidate_forces_.size(); i_bond++) { - cout << "bond force :- " << atom.candidate_forces_[i_bond] << endl; - cout << "bond " << atom.dependent_neighbour_bonds_[i_bond].first - << " <-> " << atom.dependent_neighbour_bonds_[i_bond].second - << endl; - cout << "bond weight " - << atom.dependent_neighbour_bonds_weights_[i_bond] << endl; + std::cout << "bond force :- " << atom.candidate_forces_[i_bond] + << std::endl; + std::cout << "bond " << atom.dependent_neighbour_bonds_[i_bond].first + << " <-> " << atom.dependent_neighbour_bonds_[i_bond].second + << std::endl; + std::cout << "bond weight " + << atom.dependent_neighbour_bonds_weights_[i_bond] + << std::endl; } #endif exit(0); @@ -51,8 +52,8 @@ void solver::VelocityVerlet( template <typename mesh, typename boundary_condition, typename box> void solver::VelocityVerletFIRE( mesh &_local_mesh, const bool &_apply_boundary_conditions, - const bool &_isentropic, vector<boundary_condition *> &_boundary_conditions, - bool &_to_stop) { + const bool &_isentropic, + std::vector<boundary_condition *> &_boundary_conditions, bool &_to_stop) { int number_of_time_step_increases = 0; ofstream f_timeseries; @@ -76,19 +77,19 @@ void solver::VelocityVerletFIRE( or std::isnan(_local_mesh.repatoms.thermal_forces_[nodeIndex]) #endif ) { - cout << "rank " << mpi_rank - << " detected NaN force on a repatom. Repatom id " << nodeIndex - << " , current location : " - << _local_mesh.repatoms.locations_[nodeIndex] << " , " - << _local_mesh.repatoms.mass_[nodeIndex] << " , physical force" - << _local_mesh.repatoms.forces_[nodeIndex] + std::cout << "rank " << mpi_rank + << " detected NaN force on a repatom. Repatom id " << nodeIndex + << " , current location : " + << _local_mesh.repatoms.locations_[nodeIndex] << " , " + << _local_mesh.repatoms.mass_[nodeIndex] << " , physical force" + << _local_mesh.repatoms.forces_[nodeIndex] #ifdef FINITE_TEMPERATURE - << " , thermal force " - << _local_mesh.repatoms.thermal_forces_[nodeIndex] - << " , thermal coordinates " - << _local_mesh.repatoms.thermal_coordinates_[nodeIndex] + << " , thermal force " + << _local_mesh.repatoms.thermal_forces_[nodeIndex] + << " , thermal coordinates " + << _local_mesh.repatoms.thermal_coordinates_[nodeIndex] #endif - << endl; + << std::endl; exit(0); } @@ -130,13 +131,13 @@ void solver::VelocityVerletFIRE( // +=+=+=+=<compute diagnostics (power and total force magnitude)> // +=+=+=+=+=+// - vector<double> local_diagnostics(3); + std::vector<double> local_diagnostics(3); local_diagnostics[0] = 0.0; // local power local_diagnostics[1] = 0.0; // local error (force per real atom) local_diagnostics[2] = 0.0; // error bound #ifdef FINITE_TEMPERATURE - vector<double> local_thermal_diagnostics(3); + std::vector<double> local_thermal_diagnostics(3); local_thermal_diagnostics[0] = 0.0; local_thermal_diagnostics[1] = 0.0; local_thermal_diagnostics[2] = 0.0; @@ -241,7 +242,7 @@ void solver::VelocityVerletFIRE( } } - vector<double> global_diagnostics(3); + std::vector<double> global_diagnostics(3); global_diagnostics[0] = 0.0; global_diagnostics[1] = 0.0; @@ -251,7 +252,7 @@ void solver::VelocityVerletFIRE( global_diagnostics.size()); #ifdef FINITE_TEMPERATURE - vector<double> global_thermal_diagnostics(3); + std::vector<double> global_thermal_diagnostics(3); global_thermal_diagnostics[0] = 0.0; global_thermal_diagnostics[1] = 0.0; global_thermal_diagnostics[2] = 0.0; @@ -352,7 +353,7 @@ void solver::VelocityVerletFIRE( if (FIRE_time_step < FIRE_max_time_step && FIRE_steps_post_reset >= FIRE_min_steps_reset) { FIRE_time_step = - min(FIRE_time_step * FIRE_f_increase_t, FIRE_max_time_step); + std::min(FIRE_time_step * FIRE_f_increase_t, FIRE_max_time_step); FIRE_alpha = FIRE_alpha * FIRE_f_alpha; } else if (FIRE_steps_post_reset < FIRE_min_steps_reset) { FIRE_steps_post_reset++; @@ -378,21 +379,22 @@ void solver::VelocityVerletFIRE( // atom if (mpi_rank == 0) { #ifdef OUTPUT_RELAXATION_STEPS - cout << "-------------------------------------------------" << endl; - cout << "relaxation iteration : " << solver::Solver::FIRE_iter_ - << " , time step : " << FIRE_time_step - << ", global power : " << global_diagnostics[0] - << " , global error (repatom acceleration) : " - << global_diagnostics[1] << "/" << global_diagnostics[2] - << " , alpha = " << FIRE_alpha << endl; + std::cout << "-------------------------------------------------" + << std::endl; + std::cout << "relaxation iteration : " << solver::Solver::FIRE_iter_ + << " , time step : " << FIRE_time_step + << ", global power : " << global_diagnostics[0] + << " , global error (repatom acceleration) : " + << global_diagnostics[1] << "/" << global_diagnostics[2] + << " , alpha = " << FIRE_alpha << std::endl; #ifdef FINITE_TEMPERATURE - cout << "global thermal power : " << global_thermal_diagnostics[0] - << " , global thermal error : " << global_thermal_diagnostics[1] - << "/" << global_thermal_diagnostics[2] << endl; + std::cout << "global thermal power : " << global_thermal_diagnostics[0] + << " , global thermal error : " << global_thermal_diagnostics[1] + << "/" << global_thermal_diagnostics[2] << std::endl; #endif - cout << " force L2 residual " << force_residual << endl; + std::cout << " force L2 residual " << force_residual << std::endl; #endif f_timeseries.open("./TimeSeries.dat", ios::app); @@ -400,7 +402,7 @@ void solver::VelocityVerletFIRE( << global_diagnostics[0] << " " << global_diagnostics[1] << " " << global_diagnostics[2] << " " << FIRE_time_step << " " << FIRE_alpha << " " << solver::Solver::E_global_ - << endl; + << std::endl; f_timeseries.close(); } @@ -499,11 +501,11 @@ void solver::VelocityVerletFIRE( } else { if (sigma_old < 1.0e-8) { - cout << "here " << sigma_old << " , " - << _local_mesh.repatoms.thermal_coordinates_[nodeIndex][1] - << " , " << nodeIndex << " , " << mpi_rank << " , " - << _local_mesh.repatoms.locations_[nodeIndex] << " , " - << phi_new << endl; + std::cout << "here " << sigma_old << " , " + << _local_mesh.repatoms.thermal_coordinates_[nodeIndex][1] + << " , " << nodeIndex << " , " << mpi_rank << " , " + << _local_mesh.repatoms.locations_[nodeIndex] << " , " + << phi_new << std::endl; } _local_mesh.repatoms.thermal_coordinates_[nodeIndex][1] = phi_new; diff --git a/src/vtkwriter/vtkIO.h b/src/vtkwriter/vtkIO.h index 8f6dfc17b..1f2979d4d 100644 --- a/src/vtkwriter/vtkIO.h +++ b/src/vtkwriter/vtkIO.h @@ -51,8 +51,6 @@ #include "vtkPolyData.h" #include "vtkUnstructuredGrid.h" -using namespace std; - namespace output { template <int DIM, typename mesh, typename repatomContainer, typename external_force_applicator, typename boundary_condition, @@ -67,18 +65,19 @@ template <typename meshtype, typename repatomContainer, class VTKWriter<2, meshtype, repatomContainer, external_force_applicator, boundary_condition, sampling_atom> { public: - void WriteMesh(const meshtype &, string _output_folder = "./neighbourhoods"); + void WriteMesh(const meshtype &, + std::string _output_folder = "./neighbourhoods"); void WriteVtkPointData(const meshtype &, const repatomContainer &, const external_force_applicator &, - string _output_folder = "./solution_files"); + std::string _output_folder = "./solution_files"); template <typename VTKDATA> - void WritePVTKFiles(const VTKDATA &_data, string _output_dir) { + void WritePVTKFiles(const VTKDATA &_data, std::string _output_dir) { char buffer[256]; sprintf(buffer, "%06d", outputfile_iter); - string output_iter(buffer); - string Filename = _output_dir + "/AQCNES_" + output_iter + ".pvtp"; + std::string output_iter(buffer); + std::string Filename = _output_dir + "/AQCNES_" + output_iter + ".pvtp"; vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); controller->Initialize(); @@ -108,20 +107,20 @@ public: MPI_Barrier(MPI_COMM_WORLD); } // void WriteVTKMultiBlockData(const meshtype &, - // const vector<repatom> &, - // const vector<sampling_atom> &, + // const std::vector<repatom> &, + // const std::vector<sampling_atom> &, // const int &, // const external_force_applicator &); // void WriteSamplingAtoms(const meshtype &, - // const vector<sampling_atom> &, const int &, + // const std::vector<sampling_atom> &, const int &, // const external_force_applicator &); // void WriteCompanionRepAtomData(const meshtype &_local_mesh, - // const vector<repatom> &_atoms, const int &_mpi_rank, + // const std::vector<repatom> &_atoms, const int &_mpi_rank, // const external_force_applicator &_force_applicator, - // const vector<int> &_repatom_ids, - // const vector<sampling_atom> &_sampling_atoms) + // const std::vector<int> &_repatom_ids, + // const std::vector<sampling_atom> &_sampling_atoms) // { // ofstream f_atom; // char buffer[256]; @@ -129,10 +128,10 @@ public: // sprintf(buffer, "%05d", outputfile_iter); // sprintf(rank, "%02d", mpi_rank); - // string output_rank(rank); - // string output_iter(buffer); + // std::string output_rank(rank); + // std::string output_iter(buffer); - // string OutputFile = "./repatoms_indenter/repatom_"+output_iter+"_"+rank+ + // std::string OutputFile = "./repatoms_indenter/repatom_"+output_iter+"_"+rank+ // ".dat"; // f_atom.open(OutputFile); @@ -196,7 +195,7 @@ public: // f_atom.close(); // } - // void WriteDependentNeighbourBonds(const vector<repatom> &_atoms, + // void WriteDependentNeighbourBonds(const std::vector<repatom> &_atoms, // const int &_mpi_rank) // { // if(!plotDependentNeighbouhoodBonds){ @@ -208,9 +207,9 @@ public: // char rank[256]; // sprintf(buffer, "%05d", outputfile_iter); // sprintf(rank, "%02d", mpi_rank); - // string output_iter(buffer); - // string output_rank(rank); - // string OutputFile = + // std::string output_iter(buffer); + // std::string output_rank(rank); + // std::string OutputFile = // "./solution_files/rep_atoms/dependent_neighbour_bonds_"+output_iter+"_"+rank+ // ".dat"; @@ -242,7 +241,7 @@ public: // f_bonds.close(); // } - // void WriteSamplingAtomsNeighbourhood(const vector<sampling_atom> &_atoms, + // void WriteSamplingAtomsNeighbourhood(const std::vector<sampling_atom> &_atoms, // const int &_mpi_rank) // { // if(!plotNeighbourhoods){ @@ -254,9 +253,9 @@ public: // char rank[256]; // sprintf(buffer, "%05d", outputfile_iter); // sprintf(rank, "%02d", mpi_rank); - // string output_iter(buffer); - // string output_rank(rank); - // string OutputFile = + // std::string output_iter(buffer); + // std::string output_rank(rank); + // std::string OutputFile = // "./solution_files/sampling_atoms/neighbourhoods_"+output_iter+"_"+rank+ // ".dat"; @@ -286,7 +285,7 @@ public: // } }; -// void WriteElements(const vector<int> &_elementIds, +// void WriteElements(const std::vector<int> &_elementIds, // const int &_mpi_rank) // { // ofstream f_bonds; @@ -294,9 +293,9 @@ public: // char rank[256]; // sprintf(buffer, "%05d", outputfile_iter); // sprintf(rank, "%02d", mpi_rank); -// string output_iter(buffer); -// string output_rank(rank); -// string OutputFile = +// std::string output_iter(buffer); +// std::string output_rank(rank); +// std::string OutputFile = // "./solution_files/elements_"+output_iter+"_"+rank+ ".dat"; // f_bonds.open(OutputFile); @@ -322,32 +321,33 @@ template <typename meshtype, typename repatomContainer, class VTKWriter<3, meshtype, repatomContainer, external_force_applicator, boundary_condition, sampling_atom> { public: - void WriteMesh(const meshtype &, string _output_folder = "./neighbourhoods"); + void WriteMesh(const meshtype &, + std::string _output_folder = "./neighbourhoods"); // in 3D, point data also write vtu files. Just adds its point data void WriteVtkPointData(const meshtype &, const external_force_applicator *, - const vector<boundary_condition *> &, - string _output_folder = "./solution_files"); + const std::vector<boundary_condition *> &, + std::string _output_folder = "./solution_files"); // void WriteVTKMultiBlockData(const meshtype &, - // const vector<repatom> &, - // const vector<sampling_atom> &, + // const std::vector<repatom> &, + // const std::vector<sampling_atom> &, // const int &, // const external_force_applicator &); // void WriteSamplingAtoms(const meshtype &, - // const vector<sampling_atom> &, const int &, + // const std::vector<sampling_atom> &, const int &, // const external_force_applicator &); - void WriteSubmesh(const meshtype &, const vector<size_t> &, - string _output_folder = "./neighbourhoods"); + void WriteSubmesh(const meshtype &, const std::vector<size_t> &, + std::string _output_folder = "./neighbourhoods"); template <typename VTKDATA> - void WritePVTKFiles(const VTKDATA &_data, string _output_dir) { + void WritePVTKFiles(const VTKDATA &_data, std::string _output_dir) { char buffer[256]; sprintf(buffer, "%06d", outputfile_iter); - string output_iter(buffer); - string Filename = _output_dir + "/AQCNES_" + output_iter + ".pvtu"; + std::string output_iter(buffer); + std::string Filename = _output_dir + "/AQCNES_" + output_iter + ".pvtu"; vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); controller->Initialize(); @@ -385,7 +385,7 @@ public: // public: // void WriteDATMesh(const meshtype &_local_mesh, -// const vector<repatom> &_atoms, const int &_mpi_rank, +// const std::vector<repatom> &_atoms, const int &_mpi_rank, // const int &_iteration) // { // ofstream f_mesh; @@ -395,9 +395,9 @@ public: // sprintf(buffer, "%05d", outputfile_iter); // sprintf(rank, "%01d", mpi_rank); -// string output_rank(rank); -// string output_iter(buffer); -// string OutputFile = "./DATmesh/mesh_"+output_iter+"_"+rank+".dat"; +// std::string output_rank(rank); +// std::string output_iter(buffer); +// std::string OutputFile = "./DATmesh/mesh_"+output_iter+"_"+rank+".dat"; // cout<<mpi_rank<<" : beginning the output of the file "<<endl; // cout<<mpi_rank<<" , "<<_atoms.size()<<endl; @@ -427,7 +427,7 @@ public: // } // void WriteDATPointData(const meshtype &_local_mesh, -// const vector<repatom> &_atoms, const int &_mpi_rank) +// const std::vector<repatom> &_atoms, const int &_mpi_rank) // { // ofstream f_forces; @@ -437,9 +437,9 @@ public: // sprintf(buffer, "%05d", outputfile_iter); // sprintf(rank, "%01d", mpi_rank); -// string output_rank(rank); -// string output_iter(buffer); -// string OutputFile = "./Forces/force_"+output_iter+"_"+rank+".dat"; +// std::string output_rank(rank); +// std::string output_iter(buffer); +// std::string OutputFile = "./Forces/force_"+output_iter+"_"+rank+".dat"; // f_forces.open(OutputFile); @@ -456,7 +456,7 @@ public: // } -// void WriteAtomDependenceData(const vector<repatom> &_atoms, +// void WriteAtomDependenceData(const std::vector<repatom> &_atoms, // const meshtype &_local_mesh) // { // char buffer_iter[256]; @@ -470,11 +470,11 @@ public: // sprintf(buffer_rank, "%01d", mpi_rank); // sprintf(buffer_repid, "%04d", repid); -// string output_rank(buffer_rank); -// string output_iter(buffer_iter); -// string output_repid(buffer_repid); +// std::string output_rank(buffer_rank); +// std::string output_iter(buffer_iter); +// std::string output_repid(buffer_repid); -// string OutputFile = "./repatoms/repatom_"+output_repid +// std::string OutputFile = "./repatoms/repatom_"+output_repid // +"_"+output_iter+"_"+output_rank+".dat"; // f_repatom.open(OutputFile); @@ -534,11 +534,11 @@ public: // sprintf(buffer_rank, "%01d", mpi_rank); // sprintf(buffer_elid, "%04d", elid); -// string output_rank(buffer_rank); -// string output_iter(buffer_iter); -// string output_elid(buffer_elid); +// std::string output_rank(buffer_rank); +// std::string output_iter(buffer_iter); +// std::string output_elid(buffer_elid); -// string OutputFile = "./elements/element_"+output_elid +// std::string OutputFile = "./elements/element_"+output_elid // +"_"+output_iter+"_"+output_rank+".dat"; // f_element.open(OutputFile); @@ -572,22 +572,24 @@ public: // }; template <typename cgal_point_d, typename triangulation_d, int DIM> -void WriteVTUTriangulation(const vector<cgal_point_d> &, - const triangulation_d &, const vector<int> &); +void WriteVTUTriangulation(const std::vector<cgal_point_d> &, + const triangulation_d &, const std::vector<int> &); -template <typename mesh_d> void WriteVTUMesh3D(const mesh_d &, const string &); +template <typename mesh_d> +void WriteVTUMesh3D(const mesh_d &, const std::string &); template <typename mesh_d> -void WriteVTUMesh3D_Minimal(const mesh_d &, const string &); +void WriteVTUMesh3D_Minimal(const mesh_d &, const std::string &); template <typename mesh_d> void WriteVTUMesh2D(const mesh_d &); -void WriteTetrahedra(const unordered_map<size_t, array<size_t, 4>> &, - const unordered_map<size_t, array<double, 3>> &, - const unordered_map<size_t, int> &, const string); +void WriteTetrahedra(const std::unordered_map<size_t, std::array<size_t, 4>> &, + const std::unordered_map<size_t, std::array<double, 3>> &, + const std::unordered_map<size_t, int> &, + const std::string); } // namespace output #include "vtkMeshWriters.ipp" #include "vtkPointDataWriters2D.ipp" #include "vtkPointDataWriters3D.ipp" -// #include "vtkMultiBlockWriters2D.ipp" \ No newline at end of file +// #include "vtkMultiBlockWriters2D.ipp" diff --git a/src/vtkwriter/vtkMeshWriters.ipp b/src/vtkwriter/vtkMeshWriters.ipp index 090402fbd..dfd28e287 100644 --- a/src/vtkwriter/vtkMeshWriters.ipp +++ b/src/vtkwriter/vtkMeshWriters.ipp @@ -8,7 +8,7 @@ template <typename meshtype, typename repatom, void VTKWriter<2, meshtype, repatom, external_force_applicator, boundaryCondition, sampling_atom>::WriteMesh(const meshtype &_local_mesh, - string _output_folder) { + std::string _output_folder) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkCellArray> triangles = @@ -61,8 +61,8 @@ void VTKWriter<2, meshtype, repatom, external_force_applicator, char buffer[256]; sprintf(buffer, "%06d", outputfile_iter); - string output_iter(buffer); - string Filename = _output_folder + "/AQCNES_" + output_iter + ".pvtp"; + std::string output_iter(buffer); + std::string Filename = _output_folder + "/AQCNES_" + output_iter + ".pvtp"; vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); controller->Initialize(); @@ -93,9 +93,9 @@ void VTKWriter<2, meshtype, repatom, external_force_applicator, template <> void WriteVTUTriangulation<CGAL_POINT_2, CgalTriangulation_2, 2>( - const vector<CGAL_POINT_2> &_points, + const std::vector<CGAL_POINT_2> &_points, const CgalTriangulation_2 &_triangulation, - const vector<int> &_ZeroVolumeMarkers) { + const std::vector<int> &_ZeroVolumeMarkers) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); @@ -116,7 +116,7 @@ void WriteVTUTriangulation<CGAL_POINT_2, CgalTriangulation_2, 2>( dummyData->InsertNextValue(0.0); } - vector<CGAL_POINT_2> vertices; + std::vector<CGAL_POINT_2> vertices; double element_volume; int i_cell = 0; @@ -147,8 +147,8 @@ void WriteVTUTriangulation<CGAL_POINT_2, CgalTriangulation_2, 2>( char buffer[256]; sprintf(buffer, "%06d", outputfile_iter); - string output_iter(buffer); - string Filename = "./InitialTriangulation.vtu"; + std::string output_iter(buffer); + std::string Filename = "./InitialTriangulation.vtu"; vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New(); @@ -167,7 +167,7 @@ template <typename meshtype, typename repatom, void VTKWriter<3, meshtype, repatom, external_force_applicator, boundaryCondition, sampling_atom>::WriteMesh(const meshtype &_local_mesh, - string _output_folder) { + std::string _output_folder) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkDoubleArray> elementRanks = @@ -218,8 +218,8 @@ void VTKWriter<3, meshtype, repatom, external_force_applicator, char buffer[256]; sprintf(buffer, "%06d", outputfile_iter); - string output_iter(buffer); - string Filename = _output_folder + "/AQCNES_" + output_iter + ".pvtu"; + std::string output_iter(buffer); + std::string Filename = _output_folder + "/AQCNES_" + output_iter + ".pvtu"; vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); controller->Initialize(); @@ -255,8 +255,8 @@ template <typename meshtype, typename repatom, void VTKWriter< 3, meshtype, repatom, external_force_applicator, boundaryCondition, sampling_atom>::WriteSubmesh(const meshtype &_local_mesh, - const vector<size_t> &_element_indices, - string _output_folder) { + const std::vector<size_t> &_element_indices, + std::string _output_folder) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkDoubleArray> dummy = @@ -276,7 +276,7 @@ void VTKWriter< vtkumesh->SetPoints(vtknodes); - for (vector<size_t>::const_iterator it = _element_indices.cbegin(); + for (std::vector<size_t>::const_iterator it = _element_indices.cbegin(); it != _element_indices.cend(); ++it) { vtkSmartPointer<vtkTetra> tetrahedron = vtkSmartPointer<vtkTetra>::New(); @@ -293,8 +293,8 @@ void VTKWriter< char buffer[256]; sprintf(buffer, "%06d", outputfile_iter); - string output_iter(buffer); - string Filename = _output_folder + "/overlapping_elements.vtu"; + std::string output_iter(buffer); + std::string Filename = _output_folder + "/overlapping_elements.vtu"; vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New(); @@ -320,9 +320,9 @@ void VTKWriter< template <> void WriteVTUTriangulation<CGAL_POINT_3, CgalTriangulation_3, 3>( - const vector<CGAL_POINT_3> &_points, + const std::vector<CGAL_POINT_3> &_points, const CgalTriangulation_3 &_triangulation, - const vector<int> &_ZeroVolumeMarkers) { + const std::vector<int> &_ZeroVolumeMarkers) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); @@ -349,7 +349,7 @@ void WriteVTUTriangulation<CGAL_POINT_3, CgalTriangulation_3, 3>( dummyData->InsertNextValue(0.0); } - vector<CGAL_POINT_3> vertices; + std::vector<CGAL_POINT_3> vertices; double element_volume; int i_cell = 0; @@ -385,8 +385,8 @@ void WriteVTUTriangulation<CGAL_POINT_3, CgalTriangulation_3, 3>( char buffer[256]; sprintf(buffer, "%06d", outputfile_iter); - string output_iter(buffer); - string Filename = "./InitialTriangulation.vtu"; + std::string output_iter(buffer); + std::string Filename = "./InitialTriangulation.vtu"; vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New(); @@ -400,7 +400,8 @@ void WriteVTUTriangulation<CGAL_POINT_3, CgalTriangulation_3, 3>( } template <typename mesh_d> -void WriteVTUMesh3D(const mesh_d &_local_mesh, const string &_outputDirectory) { +void WriteVTUMesh3D(const mesh_d &_local_mesh, + const std::string &_outputDirectory) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); #ifdef DISPLAY_ATOM_MARKERS @@ -453,7 +454,7 @@ void WriteVTUMesh3D(const mesh_d &_local_mesh, const string &_outputDirectory) { #endif #ifdef DISPLAY_HALO_MESH - unordered_map<size_t, int> added_halo_nodes; + std::unordered_map<size_t, int> added_halo_nodes; vtkSmartPointer<vtkDoubleArray> elementMarkers = vtkSmartPointer<vtkDoubleArray>::New(); @@ -494,7 +495,7 @@ void WriteVTUMesh3D(const mesh_d &_local_mesh, const string &_outputDirectory) { int halo_ctr = _local_mesh.meshNodes_.size(); for (const auto haloNode : _local_mesh.halo_mesh_nodes_) { - added_halo_nodes.insert(make_pair(haloNode.first, halo_ctr)); + added_halo_nodes.insert(std::make_pair(haloNode.first, halo_ctr)); vtknodes->InsertNextPoint(haloNode.second[0], haloNode.second[1], haloNode.second[2]); @@ -525,7 +526,7 @@ void WriteVTUMesh3D(const mesh_d &_local_mesh, const string &_outputDirectory) { degenerateElements->SetPoints(vtknodes); int noof_adjacents, noof_degenerates; - array<size_t, 4> adjacent_elements; + std::array<size_t, 4> adjacent_elements; noof_degenerates = 0; @@ -660,13 +661,14 @@ void WriteVTUMesh3D(const mesh_d &_local_mesh, const string &_outputDirectory) { vtkumesh->GetCellData()->AddArray(elementVolumes); vtkumesh->GetCellData()->AddArray(elementRanks); - // string OutputDirectory = "./initial_partition/"; + // std::string OutputDirectory = "./initial_partition/"; - string Filepath = _outputDirectory + "partition.pvtu"; - string BadMeshFile = _outputDirectory + "degenerate_elements.pvtu"; + std::string Filepath = _outputDirectory + "partition.pvtu"; + std::string BadMeshFile = _outputDirectory + "degenerate_elements.pvtu"; #ifdef DISPLAY_ELEMENT_MARKERS - string WeirdFile = _outputDirectory + "non_atomistic_elements.pvtu"; - string atomisticElementsFile = _outputDirectory + "atomistic_elements.pvtu"; + std::string WeirdFile = _outputDirectory + "non_atomistic_elements.pvtu"; + std::string atomisticElementsFile = + _outputDirectory + "atomistic_elements.pvtu"; #endif vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); controller->Initialize(); @@ -737,10 +739,10 @@ void WriteVTUMesh3D(const mesh_d &_local_mesh, const string &_outputDirectory) { MPI_Barrier(MPI_COMM_WORLD); } -void WriteTetrahedra(const unordered_map<size_t, array<size_t, 4>> &_tets, - const unordered_map<size_t, array<double, 3>> &_points, - const unordered_map<size_t, int> &_ranks, - const string filename) { +void WriteTetrahedra( + const std::unordered_map<size_t, std::array<size_t, 4>> &_tets, + const std::unordered_map<size_t, std::array<double, 3>> &_points, + const std::unordered_map<size_t, int> &_ranks, const std::string filename) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkIntArray> elementRanks = @@ -749,11 +751,11 @@ void WriteTetrahedra(const unordered_map<size_t, array<size_t, 4>> &_tets, elementRanks->SetNumberOfComponents(1); elementRanks->SetName("ranks"); - unordered_map<size_t, size_t> indices; + std::unordered_map<size_t, size_t> indices; size_t index = 0; for (const auto &node : _points) { - indices.insert(make_pair(node.first, index)); + indices.insert(std::make_pair(node.first, index)); vtknodes->InsertNextPoint(node.second[0], node.second[1], node.second[2]); ++index; } @@ -780,16 +782,16 @@ void WriteTetrahedra(const unordered_map<size_t, array<size_t, 4>> &_tets, char buffer[256]; sprintf(buffer, "%06d", mpi_rank); - string output_rank(buffer); + std::string output_rank(buffer); char buffer2[256]; sprintf(buffer2, "%06d", outputfile_iter); - string output_iter(buffer2); + std::string output_iter(buffer2); - string OutputDirectory = "./neighbourhoods/"; + std::string OutputDirectory = "./neighbourhoods/"; - string Filepath = OutputDirectory + filename + "_" + output_rank + "_" + - output_iter + ".vtu"; + std::string Filepath = OutputDirectory + filename + "_" + output_rank + "_" + + output_iter + ".vtu"; // outputfile_iter++; // vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); @@ -820,7 +822,7 @@ void WriteTetrahedra(const unordered_map<size_t, array<size_t, 4>> &_tets, template <typename mesh_d> void WriteVTUMesh3D_Minimal(const mesh_d &_local_mesh, - const string &_outputDirectory) { + const std::string &_outputDirectory) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); #ifdef DISPLAY_ELEMENT_MARKERS @@ -889,7 +891,7 @@ void WriteVTUMesh3D_Minimal(const mesh_d &_local_mesh, degenerateElements->SetPoints(vtknodes); int noof_adjacents, noof_degenerates; - array<size_t, 4> adjacent_elements; + std::array<size_t, 4> adjacent_elements; noof_degenerates = 0; @@ -948,11 +950,12 @@ void WriteVTUMesh3D_Minimal(const mesh_d &_local_mesh, vtkumesh->GetCellData()->AddArray(elementVolumes); vtkumesh->GetCellData()->AddArray(elementRanks); - string Filepath = _outputDirectory + "partition.pvtu"; - string BadMeshFile = _outputDirectory + "degenerate_elements.pvtu"; + std::string Filepath = _outputDirectory + "partition.pvtu"; + std::string BadMeshFile = _outputDirectory + "degenerate_elements.pvtu"; #ifdef DISPLAY_ELEMENT_MARKERS - string WeirdFile = _outputDirectory + "non_atomistic_elements.pvtu"; - string atomisticElementsFile = _outputDirectory + "atomistic_elements.pvtu"; + std::string WeirdFile = _outputDirectory + "non_atomistic_elements.pvtu"; + std::string atomisticElementsFile = + _outputDirectory + "atomistic_elements.pvtu"; #endif vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); controller->Initialize(); diff --git a/src/vtkwriter/vtkPointDataWriters2D.ipp b/src/vtkwriter/vtkPointDataWriters2D.ipp index 41dc796c2..f309fe7f3 100644 --- a/src/vtkwriter/vtkPointDataWriters2D.ipp +++ b/src/vtkwriter/vtkPointDataWriters2D.ipp @@ -7,7 +7,7 @@ void output::VTKWriter<2, meshtype, repatomContainer, external_force_applicator, WriteVtkPointData(const meshtype &_local_mesh, const repatomContainer &_local_repatom_container, const external_force_applicator &_force_applicator, - string _output_folder) { + std::string _output_folder) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkCellArray> triangles = @@ -165,8 +165,8 @@ void output::VTKWriter<2, meshtype, repatomContainer, external_force_applicator, // char buffer[256]; // sprintf(buffer, "%06d", outputfile_iter); - // string output_iter(buffer); - // string Filename = _output_folder + "/AQCNES_"+output_iter+".pvtp"; + // std::string output_iter(buffer); + // std::string Filename = _output_folder + "/AQCNES_"+output_iter+".pvtp"; // vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); // controller->Initialize(); @@ -340,8 +340,8 @@ void output::VTKWriter<2, meshtype, repatomContainer, external_force_applicator, // char buffer[256]; // sprintf(buffer, "%06d", outputfile_iter); -// string output_iter(buffer); -// string Filename = "./solution_files/AQCNES_"+output_iter+".pvtp"; +// std::string output_iter(buffer); +// std::string Filename = "./solution_files/AQCNES_"+output_iter+".pvtp"; // vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); // controller->Initialize(); @@ -369,4 +369,4 @@ void output::VTKWriter<2, meshtype, repatomContainer, external_force_applicator, // MPI_Barrier (MPI_COMM_WORLD) ; // controller->Finalize(1); -// } \ No newline at end of file +// } diff --git a/src/vtkwriter/vtkPointDataWriters3D.ipp b/src/vtkwriter/vtkPointDataWriters3D.ipp index 0e9cb6dd6..7e58675be 100644 --- a/src/vtkwriter/vtkPointDataWriters3D.ipp +++ b/src/vtkwriter/vtkPointDataWriters3D.ipp @@ -4,10 +4,11 @@ template <typename meshtype, typename repatomContainer, typename sampling_atom> void output::VTKWriter<3, meshtype, repatomContainer, external_force_applicator, boundary_condition, sampling_atom>:: - WriteVtkPointData(const meshtype &_local_mesh, - const external_force_applicator *_force_applicator, - const vector<boundary_condition *> &_boundary_conditions, - string _output_folder) { + WriteVtkPointData( + const meshtype &_local_mesh, + const external_force_applicator *_force_applicator, + const std::vector<boundary_condition *> &_boundary_conditions, + std::string _output_folder) { vtkSmartPointer<vtkPoints> vtknodes = vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkDoubleArray> elementRanks = @@ -58,11 +59,11 @@ void output::VTKWriter<3, meshtype, repatomContainer, external_force_applicator, #endif #ifdef DISPLAY_ZONES - vector<vtkSmartPointer<vtkDoubleArray>> vtkZoneData(N_zones); - string ZoneName; + std::vector<vtkSmartPointer<vtkDoubleArray>> vtkZoneData(N_zones); + std::string ZoneName; for (int zonectr = 0; zonectr < N_zones; zonectr++) { - ZoneName = "Zone_" + to_string(zonectr); + ZoneName = "Zone_" + to_std::string(zonectr); vtkZoneData[zonectr] = vtkSmartPointer<vtkDoubleArray>::New(); vtkZoneData[zonectr]->SetNumberOfComponents(1); @@ -230,9 +231,9 @@ void output::VTKWriter<3, meshtype, repatomContainer, external_force_applicator, // neighbourhood_markers->InsertNextValue(1); // } - vector<point<3>> neighbourCluster; + std::vector<point<3>> neighbourCluster; - vector<int> neighbourClusterIndices; + std::vector<int> neighbourClusterIndices; for (const auto &id : atomsForNeighbourhoodDisplay) { _local_mesh.samplingAtoms.getNodalNeighbourCluster(id, neighbourCluster); @@ -364,10 +365,10 @@ void output::VTKWriter<3, meshtype, repatomContainer, external_force_applicator, char buffer2[256]; sprintf(buffer2, "%06d", outputfile_iter); - string output_iter(buffer2); + std::string output_iter(buffer2); - string outputDir = "./solution_files/neighbourhoods_"; - string Filename = outputDir + output_iter + ".pvtu"; + std::string outputDir = "./solution_files/neighbourhoods_"; + std::string Filename = outputDir + output_iter + ".pvtu"; vtkSmartPointer<vtkMPIController> controller = vtkMPIController::New(); controller->Initialize(); @@ -508,4 +509,4 @@ void output::VTKWriter<3, meshtype, repatomContainer, external_force_applicator, // appendFilter->Update(); WritePVTKFiles(vtkumesh, _output_folder); -} \ No newline at end of file +} -- GitLab