Skip to content

Improve perf #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.5)

project(GmshToVtkAndTecplotCpp11)


add_executable(gmshToX
main.cpp

Cell2D.cpp
Face.cpp
FvmMesh2D.cpp
GmshReader.cpp
NodeIdent.cpp
NodeIdentMsh.cpp
Point.cpp

streamIO.h
)



72 changes: 41 additions & 31 deletions Cell2D.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@

#include "Cell2D.h"

unsigned Cell2D::getIdent() {
unsigned Cell2D::getIdent() const {
return this->ident;
}

Point Cell2D::getVertex1() {
return this->vertex[0];
Point& Cell2D::getVertex1() {
return vertices[0];
}

Point Cell2D::getVertex2() {
return this->vertex[1];
Point& Cell2D::getVertex2() {
return vertices[1];
}

Point Cell2D::getVertex3() {
return this->vertex[2];
Point& Cell2D::getVertex3() {
return vertices[2];
}

Point Cell2D::getVertex4() {
return this->vertex[3];
Point& Cell2D::getVertex4() {
return vertices[3];
}

Face Cell2D::getFace1() {
return this->faces[0];
Face& Cell2D::getFace1() {
return faces[0];
}

Face Cell2D::getFace2() {
return this->faces[1];
Face& Cell2D::getFace2() {
return faces[1];
}

Face Cell2D::getFace3() {
return this->faces[2];
Face& Cell2D::getFace3() {
return faces[2];
}

Face Cell2D::getFace4() {
return this->faces[3];
Face& Cell2D::getFace4() {
return faces[3];
}

Cell2D* Cell2D::getNeighbor1() {
Expand All @@ -53,16 +53,16 @@ Cell2D* Cell2D::getNeighbor4() {
return neighbor4;
}

double Cell2D::getVol() {
double x1 = this->vertex[0].getX();
double x2 = this->vertex[1].getX();
double x3 = this->vertex[2].getX();
double x4 = this->vertex[3].getX();
double Cell2D::getVol() const {
double x1 = vertices[0].getX();
double x2 = vertices[1].getX();
double x3 = vertices[2].getX();
double x4 = vertices[3].getX();

double y1 = this->vertex[0].getY();
double y2 = this->vertex[1].getY();
double y3 = this->vertex[2].getY();
double y4 = this->vertex[3].getY();
double y1 = vertices[0].getY();
double y2 = vertices[1].getY();
double y3 = vertices[2].getY();
double y4 = vertices[3].getY();

double vol = 0.5 * ((x1 - x3)*(y2 - y4) + (x4 - x2)*(y1 - y3));
return vol;
Expand All @@ -73,19 +73,19 @@ void Cell2D::setIdent(unsigned ident) {
}

void Cell2D::setVertex1(Point p) {
this->vertex[0] = p;
vertices[0] = p;
}

void Cell2D::setVertex2(Point p) {
this->vertex[1] = p;
vertices[1] = p;
}

void Cell2D::setVertex3(Point p) {
this->vertex[2] = p;
vertices[2] = p;
}

void Cell2D::setVertex4(Point p) {
this->vertex[3] = p;
vertices[3] = p;
}

void Cell2D::setNeighbor1(Cell2D* currentCell) {
Expand All @@ -105,5 +105,15 @@ void Cell2D::setNeighbor4(Cell2D* currentCell) {
}

void Cell2D::setVol(double vol) {
this->vol = vol;
this->vol = vol;
}

const std::array<Point, 4>& Cell2D::getVertices() const
{
return vertices;
}

const std::array<Face, 4>& Cell2D::getFaces() const
{
return faces;
}
33 changes: 19 additions & 14 deletions Cell2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@

#pragma once
#include "Face.h"
#include <array>

class Cell2D {
public:
Cell2D() {};
unsigned getIdent();
Point getVertex1();
Point getVertex2();
Point getVertex3();
Point getVertex4();
Face getFace1();
Face getFace2();
Face getFace3();
Face getFace4();
unsigned getIdent() const;
Point& getVertex1();
Point& getVertex2();
Point& getVertex3();
Point& getVertex4();
Face& getFace1();
Face& getFace2();
Face& getFace3();
Face& getFace4();
Cell2D* getNeighbor1();
Cell2D* getNeighbor2();
Cell2D* getNeighbor3();
Cell2D* getNeighbor4();
double getVol();
double getVol() const;

void setIdent(unsigned);
void setVertex(Point*);
Expand All @@ -38,11 +39,15 @@ class Cell2D {
void setNeighbor3(Cell2D*);
void setNeighbor4(Cell2D*);
void setVol(double);

private:

const std::array<Point, 4>& getVertices() const;

const std::array<Face, 4>& getFaces() const;

private:
unsigned ident = 0;
Point vertex[4];
Face faces[4];
std::array<Point, 4> vertices;
std::array<Face, 4> faces;
Cell2D *neighbor1 = nullptr;
Cell2D *neighbor2 = nullptr;
Cell2D *neighbor3 = nullptr;
Expand Down
14 changes: 7 additions & 7 deletions Face.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,46 @@ void Face::setP1(Point p1) {
this->p1 = p1;
}

Point Face::getP1() {
Point& Face::getP1(){
return this->p1;
}

void Face::setP2(Point p2) {
this->p2 = p2;
}

Point Face::getP2() {
Point& Face::getP2(){
return this->p2;
}

void Face::setCentroid(Point centroid) {
this->centroid = centroid;
}

Point Face::getCentroid() {
Point& Face::getCentroid(){
return this->centroid;
}

void Face::setBcTyp(int bcTyp) {
this->bcTyp = bcTyp;
}

int Face::getBcTyp() {
int Face::getBcTyp() const{
return this->bcTyp;
}

void Face::setIdFace(unsigned idFace) {
this->idFace = idFace;
}

unsigned Face::getIdFace() {
unsigned Face::getIdFace() const{
return this->idFace;
}

void Face::setArea(double area) {
this->area = area;
}

double Face::getArea() {
double Face::getArea() const{
return this->area;
}
}
12 changes: 6 additions & 6 deletions Face.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Face {
void setIdFace(unsigned);
void setArea(double);

Point getP1();
Point getP2();
Point getCentroid();
int getBcTyp();
unsigned getIdFace();
double getArea();
Point& getP1();
Point& getP2();
Point& getCentroid();
int getBcTyp() const;
unsigned getIdFace() const;
double getArea() const;

private:
Point p1, p2;
Expand Down
Loading