Path: blob/devel/ElmerGUI/netgen/libsrc/interface/writetochnog.cpp
3206 views
//1// Write Tochnog file2//3// by4//5// Andreas Seltmann6// email: [email protected]7//8#include <mystdlib.h>910#include <myadt.hpp>11#include <linalg.hpp>12#include <csg.hpp>13#include <meshing.hpp>141516namespace netgen17{18#include "writeuser.hpp"192021void WriteTochnogFormat (const Mesh & mesh,22const string & filename)23{24cout << "\nWrite Tochnog Volume Mesh" << endl;2526ofstream outfile (filename.c_str());2728outfile << "(Nodes and Elements generated with NETGEN" << endl;29outfile << " " << filename << ")" << endl;3031outfile.precision(8);3233outfile << "(Nodes)" << endl;3435int np = mesh.GetNP();36int ne = mesh.GetNE();37int i, j;3839for (i = 1; i <= np; i++)40{41outfile << "node " << " " << i << " ";42outfile << mesh.Point(i)(0) << " ";43outfile << mesh.Point(i)(1) << " ";44outfile << mesh.Point(i)(2) << "\n";45}4647int elemcnt = 0; //element counter48int finished = 0;49int indcnt = 1; //index counter5051while (!finished)52{53int actcnt = 0;54const Element & el1 = mesh.VolumeElement(1);55int non = el1.GetNP();56if (non == 4)57{58outfile << "(Elements, type=-tet4)" << endl;59}60else61{62cout << "unsupported Element type!!!" << endl;63}6465for (i = 1; i <= ne; i++)66{67const Element & el = mesh.VolumeElement(i);6869if (el.GetIndex() == indcnt)70{71actcnt++;72if (el.GetNP() != non)73{74cout << "different element-types in a subdomain are not possible!!!" << endl;75continue;76}7778elemcnt++;79outfile << "element " << elemcnt << " -tet4 ";80if (non == 4)81{82outfile << el.PNum(1) << " ";83outfile << el.PNum(2) << " ";84outfile << el.PNum(4) << " ";85outfile << el.PNum(3) << "\n";86}87else88{89cout << "unsupported Element type!!!" << endl;90for (j = 1; j <= el.GetNP(); j++)91{92outfile << el.PNum(j);93if (j != el.GetNP()) outfile << ", ";94}95outfile << "\n";96}97}98}99indcnt++;100if (elemcnt == ne) {finished = 1; cout << "all elements found by Index!" << endl;}101if (actcnt == 0) {finished = 1;}102}103104cout << "done" << endl;105}106107}108109110