Skip to content

Commit

Permalink
Namespace fem was added to almost all classes and functions of the li…
Browse files Browse the repository at this point in the history
…brary. This was done to avoid ambiguity when one uses this library with another one containing classes with the same names (for example, there is a class FiniteElement which is very popular everywhere).
  • Loading branch information
martemyev committed Mar 13, 2014
1 parent 3cfd451 commit ddc06ff
Show file tree
Hide file tree
Showing 31 changed files with 194 additions and 7 deletions.
8 changes: 8 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@

#include <string>

// options defined in cmake
#cmakedefine DEBUG
#cmakedefine HAVE_64BIT_SIZE_T

// the following two definitions are used
// to wrap the code in namespace 'fem'.
// thus all classes will be used like 'fem::NameOfClass'
#define NAMESPACE_FEM_OPEN namespace fem {
#define NAMESPACE_FEM_CLOSE }

// constants from cmake
const std::string HOME_DIRECTORY = "$ENV{HOME}";

#endif // FEM_CONFIG_H
14 changes: 11 additions & 3 deletions headers/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@

#include <string>

/* #undef DEBUG */
#define HAVE_64BIT_SIZE_T
// options defined in cmake
#define DEBUG
/* #undef HAVE_64BIT_SIZE_T */

const std::string HOME_DIRECTORY = "/u/artemyev";
// the following two definitions are used
// to wrap the code in namespace 'fem'.
// thus all classes will be used like 'fem::NameOfClass'
#define NAMESPACE_FEM_OPEN namespace fem {
#define NAMESPACE_FEM_CLOSE }

// constants from cmake
const std::string HOME_DIRECTORY = "/home/artemiev";

#endif // FEM_CONFIG_H
10 changes: 8 additions & 2 deletions headers/csr_pattern.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#ifndef FEM_SPARSE_FORMAT_H
#define FEM_SPARSE_FORMAT_H

#include <vector>
#include <set>
#include "config.h"
#include "dof_handler.h"
#include "rectangle.h"
#include <vector>
#include <set>


NAMESPACE_FEM_OPEN


enum CONNECTIVITY
{
Expand Down Expand Up @@ -119,4 +122,7 @@ class CSRPattern
CSRPattern& operator=(const CSRPattern&);
};


NAMESPACE_FEM_CLOSE

#endif // FEM_SPARSE_FORMAT_H
7 changes: 7 additions & 0 deletions headers/dof_handler.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#ifndef DOF_HANDLER_H
#define DOF_HANDLER_H

#include "config.h"
#include "point.h"
#include "edge.h"
//#include "sym_csr_pattern.h"
#include <vector>


NAMESPACE_FEM_OPEN


class FineMesh;
class SymCSRPattern;
class FiniteElement;
Expand Down Expand Up @@ -152,4 +156,7 @@ void associated_dg_edges(unsigned int ver_i,
std::vector<unsigned int> &assoc_dg_edges);



NAMESPACE_FEM_CLOSE

#endif // DOF_HANDLER_H
6 changes: 6 additions & 0 deletions headers/edge.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#ifndef EDGE_H
#define EDGE_H

#include "config.h"
#include "line.h"
#include <vector>

NAMESPACE_FEM_OPEN


class Point;
class Triangle;

Expand Down Expand Up @@ -80,4 +84,6 @@ class Edge : public Line
};


NAMESPACE_FEM_CLOSE

#endif // EDGE_H
4 changes: 4 additions & 0 deletions headers/fine_mesh.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef FINE_MESH_H
#define FINE_MESH_H

#include "config.h"
#include "point.h"
#include "triangle.h"
#include "rectangle.h"
Expand All @@ -9,6 +10,7 @@
#include <string>
#include <set>

NAMESPACE_FEM_OPEN


class FineMesh
Expand Down Expand Up @@ -200,4 +202,6 @@ class FineMesh
const Point &declared_max_point);
};

NAMESPACE_FEM_CLOSE

#endif // FINE_MESH_H
7 changes: 7 additions & 0 deletions headers/finite_element.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef FEM_FINITE_ELEMENT_H
#define FEM_FINITE_ELEMENT_H

#include "config.h"

NAMESPACE_FEM_OPEN



class FiniteElement
{
Expand All @@ -20,4 +25,6 @@ class FiniteElement
};


NAMESPACE_FEM_CLOSE

#endif // FEM_FINITE_ELEMENT_H
7 changes: 7 additions & 0 deletions headers/function.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef FEM_FUNCTION_H
#define FEM_FUNCTION_H

#include "config.h"

NAMESPACE_FEM_OPEN


class Point;

class Function
Expand All @@ -11,4 +16,6 @@ class Function
};


NAMESPACE_FEM_CLOSE

#endif // FEM_FUNCTION_H
7 changes: 7 additions & 0 deletions headers/line.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#ifndef LINE_H
#define LINE_H

#include "config.h"
#include <vector>
#include "mesh_element.h"

NAMESPACE_FEM_OPEN



/**
* Line keeps 3 numbers - the number of beginning vertex,
* the number of the ending one, and a number of physical domain
Expand Down Expand Up @@ -76,4 +81,6 @@ class Line : public MeshElement
};


NAMESPACE_FEM_CLOSE

#endif // LINE_H
7 changes: 7 additions & 0 deletions headers/math_functions.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#ifndef MATH_FUNCTIONS_H
#define MATH_FUNCTIONS_H

#include "config.h"
#include "petscvec.h"
#include "point.h"

NAMESPACE_FEM_OPEN



const double FLOAT_NUMBERS_EQUALITY_TOLERANCE = 1e-14;
const double FLOAT_NUMBERS_EQUALITY_REDUCED_TOLERANCE = 1e-6;
const double PI = 3.141592654;
Expand Down Expand Up @@ -40,4 +45,6 @@ double norm(const Point &vec);



NAMESPACE_FEM_CLOSE

#endif // MATH_FUNCTIONS_H
6 changes: 6 additions & 0 deletions headers/mesh_element.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#ifndef MESH_ELEMENT_H
#define MESH_ELEMENT_H

#include "config.h"
#include <vector>

NAMESPACE_FEM_OPEN



/**
* This class implements the most part of functionality of
Expand Down Expand Up @@ -190,4 +194,6 @@ class MeshElement
};


NAMESPACE_FEM_CLOSE

#endif // MESH_ELEMENT_H
6 changes: 6 additions & 0 deletions headers/point.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef POINT_H
#define POINT_H

#include "config.h"

NAMESPACE_FEM_OPEN



/**
* Point in 3-dimensional space.
Expand Down Expand Up @@ -75,5 +80,6 @@ class Point
};


NAMESPACE_FEM_CLOSE

#endif // POINT_H
5 changes: 5 additions & 0 deletions headers/quadrangle.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#ifndef FEM_QUADRANGLE_H
#define FEM_QUADRANGLE_H

#include "config.h"
#include "mesh_element.h"
#include "point.h"

NAMESPACE_FEM_OPEN



/**
* Quadrangle is a 2-dimensional shape with 4 straight edges.
Expand Down Expand Up @@ -125,5 +129,6 @@ class Quadrangle : public MeshElement
};


NAMESPACE_FEM_CLOSE

#endif // FEM_QUADRANGLE_H
6 changes: 6 additions & 0 deletions headers/rectangle.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#ifndef FEM_RECTANGLE_H
#define FEM_RECTANGLE_H

#include "config.h"
#include "quadrangle.h"

NAMESPACE_FEM_OPEN



class Function;

Expand Down Expand Up @@ -125,4 +129,6 @@ class Rectangle : public Quadrangle
};


NAMESPACE_FEM_CLOSE

#endif // FEM_RECTANGLE_H
7 changes: 7 additions & 0 deletions headers/result.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#ifndef RESULT_H
#define RESULT_H

#include "config.h"
#include "petscvec.h"
#include <string>
#include <vector>

NAMESPACE_FEM_OPEN



class DoFHandler;


Expand Down Expand Up @@ -64,4 +69,6 @@ class Result
};


NAMESPACE_FEM_CLOSE

#endif // RESULT_H
8 changes: 6 additions & 2 deletions headers/sym_csr_pattern.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef SYM_CSR_PATTERN_H
#define SYM_CSR_PATTERN_H

#include "config.h"
#include "csr_pattern.h"
//#include "dof_handler.h"
//#include "fine_mesh.h"

NAMESPACE_FEM_OPEN



class DoFHandler;
class FineMesh;
Expand Down Expand Up @@ -48,5 +51,6 @@ class SymCSRPattern : public CSRPattern
};


NAMESPACE_FEM_CLOSE

#endif // SYM_CSR_PATTERN_H
5 changes: 5 additions & 0 deletions headers/triangle.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#ifndef FEM_TRIANGLE_H
#define FEM_TRIANGLE_H

#include "config.h"
#include "mesh_element.h"
#include "point.h"

NAMESPACE_FEM_OPEN



class Edge;
class DoFHandler;
Expand Down Expand Up @@ -287,5 +291,6 @@ class Triangle : public MeshElement



NAMESPACE_FEM_CLOSE

#endif // FEM_TRIANGLE_H
6 changes: 6 additions & 0 deletions sources/csr_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "fine_mesh.h"
#include "auxiliary_functions.h"

NAMESPACE_FEM_OPEN



CSRPattern::CSRPattern()
{ }
Expand Down Expand Up @@ -289,3 +292,6 @@ const int* CSRPattern::nnz() const
nnz[i] = _row[i + 1] - _row[i];
return nnz;
}


NAMESPACE_FEM_CLOSE
6 changes: 6 additions & 0 deletions sources/dof_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "finite_element.h"
#include <algorithm>

NAMESPACE_FEM_OPEN



DoFHandler::DoFHandler(FineMesh *fmesh)
: _fmesh(fmesh),
Expand Down Expand Up @@ -336,3 +339,6 @@ void associated_dg_edges(unsigned int ver_i,
// the number of found edges has to be 1 (for boundary edges) or 2 (for internal edges)
expect(n_found_edges == 1 || n_found_edges == 2, "n_found_edges is not right");
}


NAMESPACE_FEM_CLOSE
Loading

0 comments on commit ddc06ff

Please sign in to comment.