Commit 71f9b9f7 authored by Stenger, Florian's avatar Stenger, Florian
Browse files

meshconv v3.21

parent c74ae574
No preview for this file type
......@@ -2805,9 +2805,8 @@ void call_read(vector<string> &args, bool test, int dim, bool add_mesh, bool enf
//test number of arguments
if(!(suffix == "vtu" || suffix == "pvtu" || suffix == "arh" || suffix == "parh"
|| suffix == "mcb" || (args.size() <= 4 && suffix == "wsxm")
|| (args.size() <= 3 && (suffix == "rwx" || suffix == "msh"))
|| args.size() <= 2)){
|| suffix == "mcb" || suffix == "msh" || (args.size() <= 4 && suffix == "wsxm")
|| (args.size() <= 3 && suffix == "rwx") || args.size() <= 2)){
error("Too many arguments in \"read\" command.");
}
......@@ -2957,15 +2956,21 @@ void call_read(vector<string> &args, bool test, int dim, bool add_mesh, bool enf
}
read_wsxm_file(args[0], *m, mirror, -h);
}else if(suffix == "msh" || suffix == "msh1"){
if(args.size() == 3){
if(args[2] == "INTERNAL_BOUNDARIES"){
read_msh_file(args[0], *m, dim, /*store_boundary_field=*/true);
bool store_boundary_field = false;
int physical_index_start = 2;
if(args.size() >= 3 && args[2] == "INTERNAL_BOUNDARIES"){
store_boundary_field = true;
physical_index_start = 3;
}
vector<int> physical_indices;
for(size_t i = physical_index_start; i < args.size(); ++i){
if(args[i][0] >= '0' && args[i][0] <= '9'){
physical_indices.push_back(ival(args[i]));
}else{
error("Invalid third argument!");
error("Invalid argument \"" + args[i] + "\"!");
}
}else{
read_msh_file(args[0], *m, dim);
}
read_msh_file(args[0], *m, dim, store_boundary_field, physical_indices);
}else if(suffix == "bt2" || suffix == "bt3" || suffix == "bt" ||
suffix == "lm2" || suffix == "lm3" || suffix == "lm"){
RefinementManager *rfm = add_refinement_manager(*m);
......
......@@ -1822,7 +1822,8 @@ void read_cdt_file(string file, Mesh &m, int dim_of_world){
//--------------------< read_msh_file >
//only triangle-meshes in 2d- or 3d-worlds supported at the moment
void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_field){
void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_field,
vector<int> physical_indices){
string buf;
int p, t, v[4], tmp_numelements = 0, tmp2_numelements = 0;
int etype, element_vertices, element_position;
......@@ -1889,13 +1890,39 @@ void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_f
element_vertices = (etype == 4)? 3 : etype;
in >> buf; //number of tags
t = ival(buf);
for(int a = 1; a <= t; ++a) in >> buf; //skip tags
if(t > 0){
in >> buf; //tag used for boundary-condition / physical-index
p = ival(buf);
if(p < 0) p = -p + 1000000;
}else{
p = 0;
}
for(int a = 2; a <= t; ++a) in >> buf; //skip other tags
for(int a = 0; a <= element_vertices; ++a) in >> buf; //coordinates
if(etype == 4){ //tetrahedron
m.dim_of_elements = 3;
}else if(etype == 2){ //triangle
if(m.dim_of_elements < 2) m.dim_of_elements = 2;
bool physical_index_match = false;
for(int phy : physical_indices){
if(phy == p){
physical_index_match = true;
break;
}
}
if(physical_indices.empty() || physical_index_match){
m.dim_of_elements = 3;
break;
}
}else if(etype == 2 && m.dim_of_elements < 2){ //triangle
bool physical_index_match = false;
for(int phy : physical_indices){
if(phy == p){
physical_index_match = true;
break;
}
}
if(physical_indices.empty() || physical_index_match){
m.dim_of_elements = 2;
}
}
}
}
......@@ -1915,11 +1942,11 @@ void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_f
getline(in, buf);
--tmp2_numelements;
}else{
element_vertices = ((etype == 4)? 3 : etype);
element_vertices = (etype == 4)? 3 : etype;
in >> buf; //number of tags
t = ival(buf);
if(t > 0){
in >> buf; //tag used for boundary-condition
in >> buf; //tag used for boundary-condition / physical-index
p = ival(buf);
if(p < 0) p = -p + 1000000;
}else{
......@@ -1932,29 +1959,58 @@ void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_f
}
if(etype == 4){ //tetrahedron
//add element
if(m.dim_of_elements == 3) add_element(m, v);
//add element if it matches one of the physical indices
bool physical_index_match = false;
for(int phy : physical_indices){
if(phy == p){
physical_index_match = true;
break;
}
}
if(physical_indices.empty() || physical_index_match) add_element(m, v);
else --tmp2_numelements;
}else if(etype == 2){ //triangle
//store boundary-information
if(m.dim_of_elements == 3){
//store boundary-information
sort3(v, new_face.v);
new_face.b_face = p;
edges.insert(new_face);
}else if(m.dim_of_elements == 2){
//add element if it matches one of the physical indices
bool physical_index_match = false;
for(int phy : physical_indices){
if(phy == p){
physical_index_match = true;
break;
}
}
if(physical_indices.empty() || physical_index_match){
add_element(m, v);
++tmp2_numelements;
}
}
//add element or reject it
if(m.dim_of_elements == 2) add_element(m, v);
else --tmp2_numelements;
--tmp2_numelements;
}else if(etype == 1){ //line
//store boundary-information
if(m.dim_of_elements == 2){
sort2(v, new_face.v);
new_face.b_face = p;
edges.insert(new_face);
}else if(m.dim_of_elements == 1){
//add element if it matches one of the physical indices
bool physical_index_match = false;
for(int phy : physical_indices){
if(phy == p){
physical_index_match = true;
break;
}
}
if(physical_indices.empty() || physical_index_match){
add_element(m, v);
++tmp2_numelements;
}
}
//add element or reject it
if(m.dim_of_elements == 1) add_element(m, v);
else --tmp2_numelements;
--tmp2_numelements;
}
}
}
......
......@@ -44,7 +44,7 @@
namespace meshconv{
using namespace std;
#define MESHCONV_VERSION "v3.20"
#define MESHCONV_VERSION "v3.21"
#define DEBUG_COUNT_AMBIGUOUS_RAYS 0
#define DEBUG_REFINE_BACKGRID 0
......@@ -811,8 +811,8 @@ void read_dae_file(string file, Mesh &m);
void read_rwx_file(string file, Mesh &m, int skip_objects);
void read_off_file(string file, Mesh &m, int dim_of_world);
void read_cdt_file(string file, Mesh &m, int dim_of_world);
void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_field=false);
void read_msh_file_1d(string file, Mesh &m, int dim_of_world);
void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_field=false,
vector<int> physical_indices=vector<int>());
#ifdef ARH1_SUPPORT
void read_arh1_file(string file, Mesh &m, vector<DataVector*> &vecs,
RefinementManager &rfm, bool read_mesh);
......
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