Commit 70689534 authored by Heinrich Schindler's avatar Heinrich Schindler
Browse files

Add enum for mesh element type (not really used much for now).

parent 121623a3
......@@ -98,6 +98,13 @@ class ComponentFieldMap : public Component {
protected:
bool m_is3d = true;
enum class ElementType {
Unknown = 0,
Serendipity = 5,
CurvedTetrahedron = 13
};
ElementType m_elementType = ElementType::CurvedTetrahedron;
// Elements
struct Element {
// Nodes
......
......@@ -9,6 +9,7 @@ namespace Garfield {
ComponentAnsys121::ComponentAnsys121() : ComponentFieldMap("Ansys121") {
m_is3d = false;
m_elementType = ElementType::Serendipity;
// Default bounding box
m_minBoundingBox[2] = -50;
m_maxBoundingBox[2] = 50;
......
......@@ -19,6 +19,7 @@ namespace Garfield {
ComponentElmer2D::ComponentElmer2D() : ComponentFieldMap("Elmer2D") {
m_is3d = false;
m_elementType = ElementType::Serendipity;
// Default bounding box
m_minBoundingBox[2] = -50;
......
......@@ -142,8 +142,12 @@ bool ComponentFieldMap::GetElement(const size_t i, size_t& mat, bool& drift,
const auto& element = m_elements[i];
mat = element.matmap;
drift = m_materials[mat].driftmedium;
nodes.resize(4);
for (size_t j = 0; j < 4; ++j) nodes[j] = element.emap[j];
size_t nNodes = 4;
if (m_elementType == ElementType::Serendipity && element.degenerate) {
nNodes = 3;
}
nodes.resize(nNodes);
for (size_t j = 0; j < nNodes; ++j) nodes[j] = element.emap[j];
return true;
}
......
......@@ -112,10 +112,10 @@ bool ViewFEMesh::Plot(const bool twod) {
}
// Plot the mesh elements.
ComponentCST* componentCST = dynamic_cast<ComponentCST*>(m_cmp);
if (componentCST) {
auto cst = dynamic_cast<ComponentCST*>(m_cmp);
if (cst) {
std::cout << m_className << "::Plot: CST component. Calling DrawCST.\n";
DrawCST(componentCST);
DrawCST(cst);
} else {
DrawElements2d();
}
......@@ -310,8 +310,9 @@ void ViewFEMesh::DrawElements2d() {
// Do not plot the drift medium.
if (driftmedium && !m_plotMeshBorders) continue;
// Do not create polygons for disabled materials.
if (m_disabledMaterial[mat]) continue;
if (m_disabledMaterial.count(mat) > 0 && m_disabledMaterial[mat]) {
continue;
}
TGraph gr;
const short col = m_colorMap.count(mat) != 0 ? m_colorMap[mat] : 1;
gr.SetLineColor(col);
......@@ -325,7 +326,6 @@ void ViewFEMesh::DrawElements2d() {
if (m_plotMeshBorders || !m_fillMesh) opt += "l";
if (m_fillMesh) opt += "f";
opt += "same";
// Get the vertex coordinates in the basic cell.
std::vector<double> vx0;
std::vector<double> vy0;
......@@ -523,7 +523,6 @@ void ViewFEMesh::DrawElements3d() {
// Loop over all elements.
const auto nElements = m_cmp->GetNumberOfElements();
for (size_t i = 0; i < nElements; ++i) {
// if (m_volumes.size() > 9990) break;
size_t mat = 0;
bool driftmedium = false;
std::vector<size_t> nodes;
......@@ -531,7 +530,9 @@ void ViewFEMesh::DrawElements3d() {
// Do not plot the drift medium.
if (driftmedium && !m_plotMeshBorders) continue;
// Do not create polygons for disabled materials.
if (m_disabledMaterial[mat]) continue;
if (m_disabledMaterial.count(mat) > 0 && m_disabledMaterial[mat]) {
continue;
}
const short col = m_colorMap.count(mat) != 0 ? m_colorMap[mat] : 1;
// Get the vertex coordinates in the basic cell.
......
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