Skip to content

Commit

Permalink
Merge branch 'hpp'
Browse files Browse the repository at this point in the history
  • Loading branch information
fionn committed Apr 19, 2020
2 parents b33191a + f099739 commit abd4bd1
Show file tree
Hide file tree
Showing 20 changed files with 80 additions and 33 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ SRCS = src/potential.cpp src/update_gauss_seidel.cpp src/electric_field.cpp \
src/initialise_boundary.cpp src/relax.cpp src/gs.cpp src/translate_y.cpp \
src/parse.cpp src/main.cpp
OBJS = $(subst .cpp,.o,$(SRCS))
HDRS = $(filter-out src/main.h, $(subst .cpp,.h,$(SRCS))) src/arguments.h
HDRS = $(filter-out src/main.hpp, $(subst .cpp,.hpp,$(SRCS))) src/arguments.hpp

all: $(TARGET)
$(info)

$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) $(OBJS) -o $(TARGET)
$(CXX) $(LDFLAGS) $(OBJS) -o $@

.PHONY: clean
clean:
@$(RM) -v $(OBJS)

.PHONY: cleanall
cleanall: clean
@$(RM) -v $(TARGET)

.PHONY: delete
delete:
@$(RM) -v u.dat e_x.dat e_y.dat cs.dat
Expand All @@ -26,3 +30,7 @@ delete:
tar:
@tar -cvJf $(TARGET).tar.xz Makefile $(SRCS) $(HDRS)

.PHONY: lint
lint:
@clang-tidy $(HDRS) $(SRCS)

24 changes: 24 additions & 0 deletions graph/plotexpng.plt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/gnuplot

#set xlabel "{/:Italic x}"
#set ylabel "{/:Italic y}"
#set zlabel "{/:Italic E_x}"

#set surface
unset colorbox
unset key
unset border
unset tics

set dgrid3d 100,100 qnorm 4
#set dgrid3d 100,100 exp
set style data lines
set xyplane 0
set view 75,310

set terminal pngcairo size 2000,2000 crop transparent
set output "ex_cairo.png"

splot "ex.dat" w l palette

pause -1
File renamed without changes.
4 changes: 2 additions & 2 deletions src/electric_field.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "potential.h"
#include "electric_field.h"
#include "potential.hpp"
#include "electric_field.hpp"
#include <fstream>

double electric_field(Potential u, bool print = false)
Expand Down
2 changes: 2 additions & 0 deletions src/electric_field.h → src/electric_field.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef ELECTRIC_H
#define ELECTRIC_H

#include "potential.hpp"

double electric_field(Potential, bool);

#endif
10 changes: 5 additions & 5 deletions src/gs.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "potential.h"
#include "initialise_boundary.h"
#include "update_gauss_seidel.h"
#include "electric_field.h"
#include "gs.h"
#include "potential.hpp"
#include "initialise_boundary.hpp"
#include "update_gauss_seidel.hpp"
#include "electric_field.hpp"
#include "gs.hpp"

double gs(Potential u, int a, int b, int da, int db, double alpha, double w)
// Wraps the Gauss-Seidel algorithm and iterates until
Expand Down
2 changes: 2 additions & 0 deletions src/gs.h → src/gs.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef GS_H
#define GS_H

#include "potential.hpp"

double gs(Potential, int, int, int, int, double, double);

#endif
4 changes: 2 additions & 2 deletions src/initialise_boundary.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "potential.h"
#include "initialise_boundary.h"
#include "potential.hpp"
#include "initialise_boundary.hpp"

void initialise_boundary(Potential u, int a, int b, int da, int db)
// Sets the boundary conditions and the value of the
Expand Down
2 changes: 2 additions & 0 deletions src/initialise_boundary.h → src/initialise_boundary.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef INITIALISE_H
#define INITIALISE_H

#include "potential.hpp"

void initialise_boundary(Potential, int, int, int, int);

#endif
14 changes: 7 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <iostream>
#include "potential.h"
#include "electric_field.h"
#include "translate_y.h"
#include "gs.h"
#include "relax.h"
#include "arguments.h"
#include "parse.h"
#include "potential.hpp"
#include "electric_field.hpp"
#include "translate_y.hpp"
#include "gs.hpp"
#include "relax.hpp"
#include "arguments.hpp"
#include "parse.hpp"

int main(int argc, char *argv[])
{
Expand Down
4 changes: 2 additions & 2 deletions src/parse.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <argp.h>
#include <iostream>
#include "arguments.h"
#include "parse.h"
#include "arguments.hpp"
#include "parse.hpp"

void clean()
{
Expand Down
2 changes: 1 addition & 1 deletion src/parse.h → src/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define PARSING_H

#include <argp.h>
#include "arguments.h"
#include "arguments.hpp"

void clean();
error_t parse_opt(int, char, struct argp_state);
Expand Down
5 changes: 3 additions & 2 deletions src/potential.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "potential.h"
#include <iostream>
#include "potential.hpp"

Potential::Potential(int m) // constructor
Potential::Potential(int m)
{
n = m;
data = new double [n * n];
Expand Down
File renamed without changes.
12 changes: 7 additions & 5 deletions src/relax.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <iostream>
#include <cmath>
#include "potential.h"
#include "initialise_boundary.h"
#include "update_gauss_seidel.h"
#include "relax.h"
#include "potential.hpp"
#include "initialise_boundary.hpp"
#include "update_gauss_seidel.hpp"
#include "relax.hpp"

double relax(Potential u, int a, int b, int da, int db, double alpha,
bool run, double argsw)
Expand All @@ -15,8 +15,10 @@ double relax(Potential u, int a, int b, int da, int db, double alpha,
else
{
double prev_iteration = INFINITY;
for(double w = 1; w < 2; w += 0.01)

for(double w = 1; w < 2; w += 0.01)
{

initialise_boundary(u, a, b, da, db);

int iteration = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/relax.h → src/relax.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RELAX_H
#define RELAX_H

#include "potential.hpp"

double relax(Potential, int, int, int, int, double, bool, double);

#endif
6 changes: 3 additions & 3 deletions src/translate_y.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <iostream>
#include "potential.h"
#include "gs.h"
#include "translate_y.h"
#include "potential.hpp"
#include "gs.hpp"
#include "translate_y.hpp"

void translate_y(Potential u, int a, int da, int db, double alpha, double w)
// Moves the container vertically through the region,
Expand Down
2 changes: 2 additions & 0 deletions src/translate_y.h → src/translate_y.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef TRANSLATE_Y_H
#define TRANSLATE_Y_H

#include "potential.hpp"

void translate_y(Potential, int, int, int, double, double);

#endif
Expand Down
4 changes: 2 additions & 2 deletions src/update_gauss_seidel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "potential.h"
#include "update_gauss_seidel.h"
#include "potential.hpp"
#include "update_gauss_seidel.hpp"

bool update_gauss_seidel(Potential u, double alpha, int a, int b, int a_len, int b_len, double w)
// Solves the Laplace equation via the Gauss-Seidel
Expand Down
2 changes: 2 additions & 0 deletions src/update_gauss_seidel.h → src/update_gauss_seidel.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef UPDATE_H
#define UPDATE_H

#include "potential.hpp"

bool update_gauss_seidel(Potential, double, int, int, int, int, double);

#endif

0 comments on commit abd4bd1

Please sign in to comment.