Skip to content

Commit

Permalink
Merge branch 'issue17-Unified_formatting_in_example_code'
Browse files Browse the repository at this point in the history
  • Loading branch information
tkphd committed Jan 23, 2017
2 parents 22f1ad1 + 5fcdfa3 commit e042bd2
Show file tree
Hide file tree
Showing 101 changed files with 3,788 additions and 2,926 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*.dvi
*.log
*.out
*.png
*.toc
*.directory
doc/MMSP.manual.pdf

# MMSP utility binaries
Expand All @@ -26,6 +28,9 @@ utility/mmsp2topo
utility/mmsp2z
utility/wrongendian

# unit testing
test/unitTestSuite

# Compiled Object files
*.slo
*.lo
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test/gtest"]
path = test/gtest
url = https://github.com/google/googletest.git
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Mesoscale Microstructure Simulation Project
# Travis Continuous Integration build script
# Questions/comments to trevor.keller@gmail.com (Trevor Keller)

language: cpp
dist: trusty
sudo: required

compiler:
- gcc

env:
- MPI=mpich2
- MPI=openmpi

notifications:
email: false

install:
- sudo apt-get update -qq -y
- sh test/travis-mpi.sh $MPI

before_script:
- cd test

script:
./build_examples.sh --np 2 --noviz --clean
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Mesoscale Microstructure Simulation Project
====
[![Build Status](https://travis-ci.org/mesoscale/mmsp.svg?branch=develop)](https://travis-ci.org/mesoscale/mmsp)

The goal of the Mesoscale Microstructure Simulation Project (MMSP) is to provide a simple,
consistent, and extensible programming interface for all grid and mesh based microstructure
Expand Down
24 changes: 0 additions & 24 deletions algorithms/evolvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,6 @@

#include "evolvers.h"

void print_progress(const int step, const int steps, const int iterations)
{
char* timestring;
static unsigned long tstart;
struct tm* timeinfo;

if (step==0) {
tstart = time(NULL);
std::time_t rawtime;
std::time( &rawtime );
timeinfo = std::localtime( &rawtime );
timestring = std::asctime(timeinfo);
timestring[std::strlen(timestring)-1] = '\0';
std::cout<<"Pass "<<std::setw(3)<<std::right<<iterations<<": "<<timestring<<" ["<<std::flush;
} else if (step==steps) {
unsigned long deltat = time(NULL)-tstart;
std::cout << "•] "
<<std::setw(2)<<std::right<<deltat/3600<<"h:"
<<std::setw(2)<<std::right<<(deltat%3600)/60<<"m:"
<<std::setw(2)<<std::right<<deltat%60<<"s"
<<" (File "<<std::setw(5)<<std::right<<iterations*steps<<")."<<std::endl;
} else if ((20 * step) % steps == 0) std::cout<<""<<std::flush;
}

template<int dim, typename T>
void interface_field_evolves(const T& dt, const T& width, const T& gamma, const T& epsilon, const T& w, const T& mu,
const MMSP::grid<dim,MMSP::sparse<T> >& former, MMSP::grid<dim,MMSP::sparse<T> >& latter, const int node)
Expand Down
2 changes: 0 additions & 2 deletions algorithms/evolvers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Definitions of methods to evolve MMSP grids
#ifndef _EVOLVERS_H_
#define _EVOLVERS_H_
void print_progress(const int step, const int steps, const int iterations);

template<int dim, typename T>
void interface_field_evolves(const T& dt, const T& width, const T& gamma, const T& epsilon, const T& w, const T& mu,
const MMSP::grid<dim,MMSP::sparse<T> >& former, MMSP::grid<dim,MMSP::sparse<T> >& latter, const int node);
Expand Down
39 changes: 8 additions & 31 deletions algorithms/generators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int seeds_to_buffer(const std::vector<MMSP::vector<int> >& vp, int* &q) {
// q should already point to an array of T[size]
if (q == NULL) {
std::cerr << "\nError in seeds_to_buffer: send_buffer not initialized." << std::endl;
exit(1);
MMSP::Abort(-1);
}
int* p = q;
for (unsigned int i=0; i<vp.size(); ++i) {
Expand All @@ -61,7 +61,7 @@ int seeds_to_buffer(const std::vector<MMSP::vector<int> >& vp, int* &q) {
void seeds_from_buffer(std::vector<MMSP::vector<int> >& vp, int* &q, const int& size) {
if (q == NULL) {
std::cerr << "\nError in seeds_from_buffer: recv_buffer not initialized." << std::endl;
exit(1);
MMSP::Abort(-1);
}
MMSP::vector<int> v(3);
for (int* p = q + 2; p < q + size; p += 3) {
Expand Down Expand Up @@ -90,8 +90,8 @@ void exact_voronoi(MMSP::grid<dim, MMSP::sparse<T> >& grid, const std::vector<st
#ifdef DEBUG
unsigned long tstart=time(NULL);
#endif
if (id==0) print_progress(0,nodes(grid));
for (int n=0; n<nodes(grid); ++n) {
if (id==0) print_progress(n,nodes(grid));
const MMSP::vector<int> x=position(grid,n);
int min_distance=std::numeric_limits<int>::max();
int identity=-1, min_identity=identity;
Expand All @@ -115,7 +115,6 @@ void exact_voronoi(MMSP::grid<dim, MMSP::sparse<T> >& grid, const std::vector<st
}
}
}
if (id==0) print_progress(n+1,nodes(grid));
MMSP::set(grid(n), min_identity) = 1.;
}
#ifdef DEBUG
Expand Down Expand Up @@ -397,7 +396,7 @@ void approximate_voronoi(MMSP::grid<dim, MMSP::sparse<T> >& grid, const std::vec
else
{
std::cerr << "Error: Invalid dimension (" << dim << ") in tessellation." << std::endl;
std::exit(1);
MMSP::Abort(-1);
}
#ifdef DEBUG
#ifdef MPI_VERSION
Expand Down Expand Up @@ -513,13 +512,13 @@ void seeds_from_file(const int x0[dim], const int x1[dim], const int g0[dim], co
std::ifstream input(seedfilename);
if (!input) {
std::cerr<<"\nError: "<<seedfilename<<" does not exist.\n"<<std::endl;
std::exit(-1);
MMSP::Abort(-1);
}
int seed_dim;
input >> seed_dim;
if (dim!=seed_dim) {
std::cerr<<"\nError: "<<seedfilename<<" is "<<seed_dim<<"-dimensional.\n"<<std::endl;
std::exit(-1);
MMSP::Abort(-1);
}
std::vector<MMSP::vector<int> > local_seeds; // blank for now
seeds.clear();
Expand All @@ -532,7 +531,7 @@ void seeds_from_file(const int x0[dim], const int x1[dim], const int g0[dim], co
input >> s;
if (s>1.0001) {
std::cerr<<"\nError: Seeds in "<<seedfilename<<" need to be normalized (found s="<<s<<").\n"<<std::endl;
std::exit(-1);
MMSP::Abort(-1);
}
// Seeds in file should be normalized (unit line, square, or cube).
seed[d]=g0[d]+(g1[d]-g0[d]-1)*s;
Expand Down Expand Up @@ -570,7 +569,7 @@ void honeycomb_seeds(const int x0[dim], const int x1[dim], const int g0[dim], co
}
} else {
std::cerr<<"\nError: "<<dim<<"-dimensional honeycomb is not implemented yet.\n"<<std::endl;
std::exit(-1);
MMSP::Abort(-1);
}
seedswap(seeds);
}
Expand Down Expand Up @@ -602,26 +601,4 @@ void tessellate(MMSP::grid<dim, MMSP::sparse<T> >& grid, const int& nseeds) {
#endif
} // tessellate

void print_progress(const int i, const int N) {
char* timestring;
static unsigned long tstart;
struct tm* timeinfo;

if (i==0) {
tstart = time(NULL);
std::time_t rawtime;
std::time( &rawtime );
timeinfo = std::localtime( &rawtime );
timestring = std::asctime(timeinfo);
timestring[std::strlen(timestring)-1] = '\0';
std::cout<<timestring<<" ["<<std::flush;
} else if (i==N) {
unsigned long deltat = time(NULL)-tstart;
std::cout<<"•] "<<std::setw(2)<<std::right<<deltat/3600<<"h:"
<<std::setw(2)<<std::right<<(deltat%3600)/60<<"m:"
<<std::setw(2)<<std::right<<deltat%60<<"s"
<<'.'<<std::endl;
} else if ((20 * i) % N == 0) std::cout<<""<<std::flush;
}

#endif // _GENERATORS_
2 changes: 0 additions & 2 deletions algorithms/generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ void seeds_from_file(const int x0[dim], const int x1[dim], const int g0[dim], co
template<int dim>
void honeycomb_seeds(const int x0[dim], const int x1[dim], const int g0[dim], const int g1[dim], const int a, std::vector<std::vector<MMSP::vector<int> > >& seeds);

void print_progress(const int i, const int N);

#endif // _GENERATORS_H_
23 changes: 0 additions & 23 deletions algorithms/tessellate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include <cassert>
#include "MersenneTwister.h"

void print_progress(const int i, const int N);

template <int dim, typename T> double radius(const MMSP::vector<T>& a, const MMSP::vector<T>& b) {
double radius=0.0;
for (int d=0; d<dim; ++d) radius+=std::pow(double(b[d]-a[d]), 2.0);
Expand Down Expand Up @@ -604,25 +602,4 @@ void tessellate(MMSP::grid<dim, sparse<T> >& grid, const std::string& seed_filen

} // namespace

void print_progress(const int i, const int N) {
char* timestring;
static unsigned long tstart;
struct tm* timeinfo;

if (i==0) {
tstart = time(NULL);
std::time_t rawtime;
std::time( &rawtime );
timeinfo = std::localtime( &rawtime );
timestring = std::asctime(timeinfo);
timestring[std::strlen(timestring)-1] = '\0';
std::cout<<timestring<<" ["<<std::flush;
} else if (i==N-1) {
unsigned long deltat = time(NULL)-tstart;
std::cout<<"•] "<<std::setw(2)<<std::right<<deltat/3600<<"h:"
<<std::setw(2)<<std::right<<(deltat%3600)/60<<"m:"
<<std::setw(2)<<std::right<<deltat%60<<"s"
<<'.'<<std::endl;
} else if ((20 * i) % N == 0) std::cout<<""<<std::flush;
}
#endif
Loading

0 comments on commit e042bd2

Please sign in to comment.