Skip to content
Snippets Groups Projects
Commit bf1e2512 authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

output ALL elements including line elements and also zero area/volume elemens.

parent 486a9959
No related branches found
No related tags found
No related merge requests found
...@@ -263,7 +263,7 @@ int MeshIO::write(std::ostream &out) ...@@ -263,7 +263,7 @@ int MeshIO::write(std::ostream &out)
out << "$ELEMENTS\n" out << "$ELEMENTS\n"
<< " "; << " ";
writeElementsExceptLines(_mesh->getElements(), out); writeElements(_mesh->getElements(), out);
out << " $LAYER\n" out << " $LAYER\n"
<< " 0\n" << " 0\n"
...@@ -277,37 +277,18 @@ void MeshIO::setMesh(const MeshLib::Mesh* mesh) ...@@ -277,37 +277,18 @@ void MeshIO::setMesh(const MeshLib::Mesh* mesh)
_mesh = mesh; _mesh = mesh;
} }
void MeshIO::writeElementsExceptLines(std::vector<MeshLib::Element*> const& ele_vec, void MeshIO::writeElements(std::vector<MeshLib::Element*> const& ele_vec,
std::ostream &out) std::ostream &out)
{ {
const size_t ele_vector_size (ele_vec.size()); const size_t ele_vector_size (ele_vec.size());
const double epsilon (std::numeric_limits<double>::epsilon());
std::vector<bool> non_line_element (ele_vector_size, true);
std::vector<bool> non_null_element (ele_vector_size, true);
size_t n_elements(0);
out << ele_vector_size << "\n";
for (size_t i(0); i < ele_vector_size; ++i) { for (size_t i(0); i < ele_vector_size; ++i) {
if ((ele_vec[i])->getGeomType() == MeshElemType::LINE) { out << i << " " << ele_vec[i]->getValue() << " " << MeshElemType2String(ele_vec[i]->getGeomType()) << " ";
non_line_element[i] = false; unsigned nElemNodes (ele_vec[i]->getNNodes());
non_null_element[i] = false; for(size_t j = 0; j < nElemNodes; ++j)
} else { out << ele_vec[i]->getNode(j)->getID() << " ";
if (ele_vec[i]->getContent() < epsilon) { out << "\n";
non_null_element[i] = false;
} else {
++n_elements;
}
}
}
out << n_elements << "\n";
for (size_t i(0), k(0); i < ele_vector_size; ++i) {
if (non_line_element[i] && non_null_element[i]) {
out << k << " " << ele_vec[i]->getValue() << " " << MeshElemType2String(ele_vec[i]->getGeomType()) << " ";
unsigned nElemNodes (ele_vec[i]->getNNodes());
for(size_t j = 0; j < nElemNodes; ++j)
out << ele_vec[i]->getNode(j)->getID() << " ";
out << "\n";
++k;
}
} }
} }
......
...@@ -53,7 +53,7 @@ protected: ...@@ -53,7 +53,7 @@ protected:
int write(std::ostream &out); int write(std::ostream &out);
private: private:
void writeElementsExceptLines(std::vector<MeshLib::Element*> const& ele_vec, std::ostream &out); void writeElements(std::vector<MeshLib::Element*> const& ele_vec, std::ostream &out);
MeshLib::Element* readElement(const std::string& line, const std::vector<MeshLib::Node*> &nodes); MeshLib::Element* readElement(const std::string& line, const std::vector<MeshLib::Node*> &nodes);
double* _edge_length[2]; double* _edge_length[2];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment