In this tutorial, meshes in one, two and three dimensions are shown. This tutorial does not describe a program which can be used to generate an executable. Therefore, there is no need to type make meshes
The mesh is the interval from 1 to 5 with two cells. One is (1,2) and the other is (2,5). They are coupled in the class Line which makes it possible to loop over the cells.
A scanner is used to loop over all cells in a mesh. S is the scanner for this mesh. It is used in the constructor of the space to create the elements on the cells of the mesh. With the ++ operator it is possible to loop over the cells of the mesh. The constructor of the space shows an example of the usage of a scanner and its ++ operator.
The destructor of the mesh removes all components which where created in the constructor.
The info member prints the two cells of the mesh. It is used by the output operator of the base class concepts::OutputOperator.
The order of the vertices in the constructor of the edge does not matter. Every edge on the boundary of the domain gets a unique number. This number is used to identify the edge when specifying boundary conditions. 0 is reserved for free edges (and is the default) and should therefore not be used to specify a bounary condition.
The order of the edges matters: they must be listed counterclockwise.
The element map is given by the three vertices beginning with the vertices of the first edge from the construction of the triangle. As for the edges, the vertices have to be ordered counterclockwise.
public:
LshapedCube();
virtual ~LshapedCube();
unsigned int ncell()
const {
return 3; }
virtual std::ostream&
info(std::ostream& os)
const;
private:
unsigned int idx_;
public:
S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
bool eos() const { return idx_ == 3; }
};
};
LshapedCube::LshapedCube() {
for (uint i = 0; i < 16; ++i)
quad_[0] =
new concepts::Quad(*edg_[0], *edg_[1], *edg_[2], *edg_[3]);
quad_[1] =
new concepts::Quad(*edg_[3], *edg_[4], *edg_[5], *edg_[6]);
quad_[2] =
new concepts::Quad(*edg_[6], *edg_[7], *edg_[8], *edg_[9]);
quad_[3] =
new concepts::Quad(*edg_[10], *edg_[11], *edg_[12], *edg_[13]);
quad_[4] =
new concepts::Quad(*edg_[13], *edg_[14], *edg_[15], *edg_[16]);
quad_[5] =
new concepts::Quad(*edg_[16], *edg_[17], *edg_[18], *edg_[19]);
quad_[6] =
new concepts::Quad(*edg_[0], *edg_[21], *edg_[10], *edg_[20]);
quad_[7] =
new concepts::Quad(*edg_[1], *edg_[22], *edg_[11], *edg_[21]);
quad_[8] =
new concepts::Quad(*edg_[2], *edg_[23], *edg_[12], *edg_[22]);
quad_[9] =
new concepts::Quad(*edg_[4], *edg_[24], *edg_[14], *edg_[23]);
quad_[10] =
new concepts::Quad(*edg_[5], *edg_[25], *edg_[15], *edg_[24]);
quad_[11] =
new concepts::Quad(*edg_[7], *edg_[26], *edg_[17], *edg_[25]);
quad_[12] =
new concepts::Quad(*edg_[8], *edg_[27], *edg_[18], *edg_[26]);
quad_[13] =
new concepts::Quad(*edg_[9], *edg_[20], *edg_[19], *edg_[27]);
quad_[14] =
new concepts::Quad(*edg_[3], *edg_[23], *edg_[13], *edg_[20]);
quad_[15] =
new concepts::Quad(*edg_[6], *edg_[25], *edg_[16], *edg_[20]);
*quad_[8], *quad_[14], *quad_[3]);
*quad_[9], *quad_[10], *quad_[4]);
public:
virtual ~Line();
unsigned int ncell()
const {
return 2; }
virtual std::ostream&
info(std::ostream& os)
const;
private:
unsigned int idx_;
public:
S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
bool eos() const { return idx_ == 2; }
};
};
}
Line::~Line() {
for (int i = 0; i < 2; ++i)
delete cell_[i];
for (int i = 0; i < 2; ++i)
delete edg_[i];
for (int i = 0; i < 3; ++i)
delete vtx_[i];
}
std::ostream& Line::info(std::ostream& os) const {
os << "Line(" << *cell_[0] << ", " << *cell_[1] << ')';
return os;
}
public:
LshapedTriangle();
virtual ~LshapedTriangle();
unsigned int ncell()
const {
return 4; }
virtual std::ostream&
info(std::ostream& os)
const;
private:
unsigned int idx_;
public:
S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
bool eos() const { return idx_ == 4; }
};
};
LshapedTriangle::LshapedTriangle() {
for (uint i = 0; i < 6; ++i)
}
LshapedTriangle::~LshapedTriangle() {
for (int i = 0; i < 4; ++i)
delete cell_[i];
for (int i = 0; i < 4; ++i)
delete tri_[i];
for (int i = 0; i < 9; ++i)
delete edg_[i];
for (int i = 0; i < 6; ++i)
delete vtx_[i];
}
std::ostream& LshapedTriangle::info(std::ostream& os) const {
os << "LshapedTriangle(" << *cell_[0] << ", " << *cell_[1] << ", "
<< *cell_[2] << ", " << *cell_[3] << ')';
return os;
}
public:
LshapedQuad();
virtual ~LshapedQuad();
unsigned int ncell()
const {
return 3; }
virtual std::ostream&
info(std::ostream& os)
const;
private:
unsigned int idx_;
public:
S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
bool eos() const { return idx_ == 3; }
};
};
LshapedQuad::LshapedQuad() {
for (uint i = 0; i < 8; ++i)
quad_[0] =
new concepts::Quad(*edg_[0], *edg_[1], *edg_[2], *edg_[3]);
quad_[1] =
new concepts::Quad(*edg_[3], *edg_[4], *edg_[5], *edg_[6]);
quad_[2] =
new concepts::Quad(*edg_[6], *edg_[7], *edg_[8], *edg_[9]);
}
LshapedQuad::~LshapedQuad() {
for (int i = 0; i < 3; ++i)
delete cell_[i];
for (int i = 0; i < 3; ++i)
delete quad_[i];
for (int i = 0; i < 10; ++i)
delete edg_[i];
for (int i = 0; i < 8; ++i)
delete vtx_[i];
}
std::ostream& LshapedQuad::info(std::ostream& os) const {
os << "LshapedQuad(" << *cell_[0] << ", " << *cell_[1] << ", "
<< *cell_[2] << ')';
return os;
}
public:
LshapedCube();
virtual ~LshapedCube();
unsigned int ncell()
const {
return 3; }
virtual std::ostream&
info(std::ostream& os)
const;
private:
unsigned int idx_;
public:
S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
bool eos() const { return idx_ == 3; }
};
};
LshapedCube::LshapedCube() {
for (uint i = 0; i < 16; ++i)
quad_[0] =
new concepts::Quad(*edg_[0], *edg_[1], *edg_[2], *edg_[3]);
quad_[1] =
new concepts::Quad(*edg_[3], *edg_[4], *edg_[5], *edg_[6]);
quad_[2] =
new concepts::Quad(*edg_[6], *edg_[7], *edg_[8], *edg_[9]);
quad_[3] =
new concepts::Quad(*edg_[10], *edg_[11], *edg_[12], *edg_[13]);
quad_[4] =
new concepts::Quad(*edg_[13], *edg_[14], *edg_[15], *edg_[16]);
quad_[5] =
new concepts::Quad(*edg_[16], *edg_[17], *edg_[18], *edg_[19]);
quad_[6] =
new concepts::Quad(*edg_[0], *edg_[21], *edg_[10], *edg_[20]);
quad_[7] =
new concepts::Quad(*edg_[1], *edg_[22], *edg_[11], *edg_[21]);
quad_[8] =
new concepts::Quad(*edg_[2], *edg_[23], *edg_[12], *edg_[22]);
quad_[9] =
new concepts::Quad(*edg_[4], *edg_[24], *edg_[14], *edg_[23]);
quad_[10] =
new concepts::Quad(*edg_[5], *edg_[25], *edg_[15], *edg_[24]);
quad_[11] =
new concepts::Quad(*edg_[7], *edg_[26], *edg_[17], *edg_[25]);
quad_[12] =
new concepts::Quad(*edg_[8], *edg_[27], *edg_[18], *edg_[26]);
quad_[13] =
new concepts::Quad(*edg_[9], *edg_[20], *edg_[19], *edg_[27]);
quad_[14] =
new concepts::Quad(*edg_[3], *edg_[23], *edg_[13], *edg_[20]);
quad_[15] =
new concepts::Quad(*edg_[6], *edg_[25], *edg_[16], *edg_[20]);
*quad_[8], *quad_[14], *quad_[3]);
*quad_[9], *quad_[10], *quad_[4]);
*quad_[15], *quad_[11], *quad_[5]);
(*hex_[0],
);
(*hex_[1],
);
(*hex_[2],
);
}
LshapedCube::~LshapedCube() {
for (int i = 0; i < 3; ++i)
delete cell_[i];
for (int i = 0; i < 3; ++i)
delete hex_[i];
for (int i = 0; i < 16; ++i)
delete quad_[i];
for (int i = 0; i < 28; ++i)
delete edg_[i];
for (int i = 0; i < 16; ++i)
delete vtx_[i];
}
std::ostream& LshapedCube::info(std::ostream& os) const {
os << "LshapedCube(" << *cell_[0] << ", " << *cell_[1] << ", "
<< *cell_[2] << ')';
return os;
}