Skip to content

Commit

Permalink
Public Helmholtz FMM
Browse files Browse the repository at this point in the history
  • Loading branch information
ccecka committed Dec 8, 2013
1 parent fa899f8 commit 7c3f5ee
Show file tree
Hide file tree
Showing 21 changed files with 5,544 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Box.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef BOX_H
#define BOX_H

#include "General.hpp"
#include "Vec3.hpp"
#include "NFunction.hpp"

class Box
{
NFunction M; // Multipole (outgoing) expansion
NFunction L; // Local (incoming) expansion

public:
typedef vector<int> PointList;
typedef PointList::iterator pointIter;

int n; // The box number
Vec3 center; // The box center

Box* parent; // A pointer to this box's parent
PointList pointIndex; // If leaf, contains indices of points it contains

Box() {}
Box( int n_, const Vec3& center_ ) : n(n_), center(center_) {}
~Box() {}

inline void addPointIndex( int index ) {
pointIndex.push_back( index );
}

inline void makeMultipole( Quadrature* q ) {
M = NFunction(q);
}

inline void makeLocal( Quadrature* q ) {
L = NFunction(q);
}

inline NFunction& getMultipole() {
return M;
}

inline NFunction& getLocal() {
return L;
}

private:
// Disable Copy and Assignment
Box(const Box& S) { (void) S; }
void operator=(const Box& S) { (void) S; }
};

#endif
21 changes: 21 additions & 0 deletions Direct.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef DIRECT_H
#define DIRECT_H

template <typename FUNC>
void Direct(FUNC K, const vector<Vec3>& p,
const vector<complex>& psi, vector<complex>& omega)
{
int N = p.size();
for( int m = 0; m < N; ++m ) {
const Vec3& pm = p[m];
omega[m] = 0;
for( int n = 0; n != m; ++n ) {
double r = pm.dist(p[n]);
complex E = K(r);
omega[m] += psi[n] * E;
omega[n] += psi[m] * E;
}
}
}

#endif
Loading

0 comments on commit 7c3f5ee

Please sign in to comment.