Commit e7e06b95 authored by JasonPries's avatar JasonPries
Browse files

Partial commit of work done at home

parent 0a553c0d
<component name="ProjectDictionaryState">
<dictionary name="jpries">
<words>
<w>discretization</w>
<w>eigen</w>
<w>supremum</w>
<w>tangency</w>
......
......@@ -18,6 +18,7 @@ add_subdirectory(./lib/)
include_directories(./src/)
include_directories(./src/Sketch/include/)
include_directories(./src/Mesh/include/)
include_directories(./src/Physics/include/)
add_subdirectory(./src/)
......
include_directories(./Sketch/)
include_directories(./Mesh/)
include_directories(./Physics/)
add_subdirectory(./Sketch/)
add_subdirectory(./Mesh/)
\ No newline at end of file
add_subdirectory(./Mesh/)
add_subdirectory(./Physics/)
\ No newline at end of file
......@@ -5,7 +5,8 @@ set(SOURCE_FILES
./src/Mesh.h ./src/Mesh.cpp
./src/Edge.h ./src/Edge.cpp
./src/Point.h ./src/Point.cpp)
./src/Point.h ./src/Point.cpp
)
add_library(mesh SHARED ${SOURCE_FILES})
......
#ifndef OERSTED_MESH_HPP
#define OERSTED_MESH_HPP
#include <boost/filesystem.hpp>
#include "../src/Mesh.h"
#include "../src/Edge.h"
#include "../src/Point.h"
......
project(Oersted_Physics)
set(SOURCE_FILES
./include/Physics.hpp
#./src/PhysicsCommon.h
#./src/Physics.h ./src/Physics.cpp
#./src/Operator.h ./src/Operator.cpp
#./src/Discretization.h ./src/Discretization.cpp
./src/QuadratureRule.h ./src/QuadratureRule.cpp
./src/Triangle.h ./src/Triangle.cpp
./src/Node.h ./src/Node.cpp
./src/FiniteElementMesh.h ./src/FiniteElementMesh.cpp
)
add_library(physics SHARED ${SOURCE_FILES})
#target_link_libraries(sketch ${Boost_LIBRARIES})
\ No newline at end of file
#ifndef OERSTED_PHYSICS_HPP
#define OERSTED_PHYSICS_HPP
//#include "../src/PhysicsCommon.h"
//#include "../src/Physics.h"
//#include "../src/Discretization.h"
//#include "../src/Operator.h"
#include "../src/Node.h"
#include "../src/QuadratureRule.h"
#include "../src/Triangle.h"
#include "../src/FiniteElementMesh.h"
#endif //OERSTED_PHYSICS_HPP
#include "Discretization.h"
#ifndef OERSTED_DISCRETIZATION_H
#define OERSTED_DISCRETIZATION_H
#include "PhysicsCommon.h"
template<Dimension d> class Discretization {};
template<Order M> class Triangle {
public:
size_t Nodes[(M+2)*(M+3)/2];
};
template<Dimension d, Order M> class FiniteElementMesh : public Discretization<d> {};
template<Order M> class FiniteElementMesh<2,M> : public Discretization<2> {
public:
FiniteElementMesh() : Discretization() {};
std::vector<Triangle<M>> Triangles;
};
#endif //OERSTED_DISCRETIZATION_H
\ No newline at end of file
//
// Created by jpries on 12/20/16.
//
#include "FiniteElementMesh.h"
#ifndef OERSTED_FINITEELEMENTMESH_H
#define OERSTED_FINITEELEMENTMESH_H
#include <vector>
#include "Eigen"
#include "Node.h"
#include "Triangle.h"
template<size_t M, size_t Q>
class QuadratureDerivatives {
private:
SmallVector<M> Value[Q];
};
template<size_t Q>
class QuadratureDerivatives<2, Q> {
public:
double dx(size_t i) { return d[i].x(); };
double dy(size_t i) { return d[i].y(); };
private:
XY d[Q];
};
template<size_t Q>
class QuadratureDerivatives<3, Q> {
public:
double dx(size_t i) { return d[i].x(); };
double dy(size_t i) { return d[i].y(); };
double dz(size_t i) { return d[i].z(); };
private:
XYZ d[Q];
};
template<size_t M, size_t N>
class FiniteElementMesh {
};
template<size_t P>
class FiniteElementMesh<2, P> {
public:
FiniteElementMesh(std::vector<XY> nodes, std::vector<Triangle<P>> tris) : Nodes(nodes), Triangles(tris) {};
std::vector<XY> const nodes() { return Nodes; };
std::vector<Triangle<P>> const triangles() { return Triangles; };
protected:
std::vector<XY> Nodes;
std::vector<Triangle<P>> Triangles;
};
#endif //OERSTED_FINITEELEMENTMESH_H
#ifndef OERSTED_NODE_H
#define OERSTED_NODE_H
// TODO: Const
template<size_t N>
class SmallVector {
private:
double Value[N];
};
template<size_t M, size_t N>
class SmallMatrix {
};
template<size_t M, bool Symmetric>
class SquareMatrix : public SmallMatrix<M, M> {
};
template<>
class SmallVector<2> {
public:
SmallVector() : Value{} {};
SmallVector(double x, double y) : Value{x, y} {};
double value(size_t i) const { return Value[i]; };
double x() const { return Value[0]; };
void x(double val) { Value[0] = val; };
double y() const { return Value[1]; };
void y(double val) { Value[1] = val; };
private:
double Value[2];
};
using XY = SmallVector<2>;
template<>
class SmallVector<3> {
public:
SmallVector() : Value{} {};
SmallVector(double x, double y, double z) : Value{x, y, z} {};
double value(size_t i) const { return Value[i]; }
double x() const { return Value[0]; }
double y() const { return Value[1]; }
double z() const { return Value[2]; }
private:
double Value[3];
};
using XYZ = SmallVector<3>;
template<>
class SquareMatrix<2, true> {
public:
SquareMatrix() : Value{} {};
SquareMatrix(double xx, double xy, double yy) : Value{xx, xy, yy} {};
double xx() const { return Value[0]; };
double xy() const { return Value[1]; };
double yx() const { return Value[1]; };
double yy() const { return Value[2]; };
private:
double Value[3];
};
template<>
class SquareMatrix<2, false> {
public:
SquareMatrix() : Value{} {};
SquareMatrix(double xx, double xy, double yx, double yy) : Value{xx, xy, yx, yy} {};
double xx() const { return Value[0]; };
double xy() const { return Value[1]; };
double yx() const { return Value[2]; };
double yy() const { return Value[3]; };
private:
double Value[4];
};
#endif //OERSTED_NODE_H
#include "Operator.h"
\ No newline at end of file
#ifndef OERSTED_OPERATOR_H
#define OERSTED_OPERATOR_H
#include <memory>
#include "Eigen"
#include "PhysicsCommon.h"
template<Dimension d> class Discretization;
template<VectorSpace vs, Dimension d>
class Operator {
public:
Eigen::VectorXd operator()(Eigen::VectorXd vec) { return Matrix * vec;};
Eigen::MatrixXd operator()(Eigen::MatrixXd mat) { return Matrix * mat; };
static const VectorSpace Space = vs;
static const Dimension Dim = d;
protected:
Operator(std::shared_ptr<Discretization<d>> dsc) : Domain(dsc) {};
std::shared_ptr<Discretization<d>> Domain;
Eigen::MatrixXd Matrix;
};
template<VectorSpace vs, Dimension d> class Curl : public Operator<vs,d> {
public:
Curl(std::shared_ptr<Discretization<d>> dsc) : Operator<vs,d>(dsc) {};
};
#endif //OERSTED_OPERATOR_H
#include "Physics.h"
#ifndef OERSTED_PHYSICS_H
#define OERSTED_PHYSICS_H
#include <memory>
#include "PhysicsCommon.h"
#include "Operator.h"
#include "Discretization.h"
template<class op_p, class op_d, Dimension d>
class Physics {
public:
Physics(std::shared_ptr<Discretization<d>> dsc) : PrimalOperator(std::make_shared<op_p>(dsc)), DualOperator(std::make_shared<op_d>(dsc)), Domain(dsc) {};
protected:
std::shared_ptr<Operator<Primal, d>> PrimalOperator;
std::shared_ptr<Operator<Dual, d>> DualOperator;
std::shared_ptr<Discretization<d>> Domain;
};
#endif //OERSTED_PHYSICS_H
#ifndef OERSTED_PHYSICSENUMERATIONS_H
#define OERSTED_PHYSICSENUMERATIONS_H
enum class VectorSpace {
Primal, Dual
};
#define Primal VectorSpace::Primal
#define Dual VectorSpace::Dual
typedef size_t Dimension;
typedef size_t Order;
#endif //OERSTED_PHYSICSENUMERATIONS_H
#include "QuadratureRule.h"
\ No newline at end of file
#ifndef OERSTED_QUADRATURERULE_H
#define OERSTED_QUADRATURERULE_H
template<size_t Q>
struct TriangleQuadratureRule {
};
template<>
struct TriangleQuadratureRule<1> {
static constexpr size_t size{1};
static constexpr double a[1]{1.0 / 3.0};
static constexpr double b[1]{1.0 / 3.0};
static constexpr double w[1]{1.0};
};
constexpr double TriangleQuadratureRule<1>::a[];
constexpr double TriangleQuadratureRule<1>::b[];
constexpr double TriangleQuadratureRule<1>::w[];
template<>
struct TriangleQuadratureRule<2> {
static constexpr size_t size{3};
static constexpr double a[3]{2.0 / 3.0, 1.0 / 6.0, 1.0 / 6.0};
static constexpr double b[3]{1.0 / 6.0, 2.0 / 3.0, 1.0 / 6.0};
static constexpr double w[3]{1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0};
};
constexpr double TriangleQuadratureRule<2>::a[];
constexpr double TriangleQuadratureRule<2>::b[];
constexpr double TriangleQuadratureRule<2>::w[];
#endif //OERSTED_QUADRATURERULE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment