Toggle navigation
Documentation
Big picture
The finite element method
The data structure
Not-so-quick guide
Optimisation
Order of action functions
Example codes and tutorials
List of example codes and tutorials
Meshing
Solvers
MPI parallel processing
Post-processing/visualisation
Other
Change log
Creating documentation
Coding conventions
Index
FAQ
Get it
Installation guide
Get code from subversion repository
Get code as tar file
Copyright
About
People
Contact/Get involved
Publications
Acknowledgements
Picture show
Go
demo_drivers
meshing
mesh_from_geompack
convert_geom_file.cc
Go to the documentation of this file.
1
//LIC// ====================================================================
2
//LIC// This file forms part of oomph-lib, the object-oriented,
3
//LIC// multi-physics finite-element library, available
4
//LIC// at http://www.oomph-lib.org.
5
//LIC//
6
//LIC// Version 1.0; svn revision $LastChangedRevision$
7
//LIC//
8
//LIC// $LastChangedDate$
9
//LIC//
10
//LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11
//LIC//
12
//LIC// This library is free software; you can redistribute it and/or
13
//LIC// modify it under the terms of the GNU Lesser General Public
14
//LIC// License as published by the Free Software Foundation; either
15
//LIC// version 2.1 of the License, or (at your option) any later version.
16
//LIC//
17
//LIC// This library is distributed in the hope that it will be useful,
18
//LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
//LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
//LIC// Lesser General Public License for more details.
21
//LIC//
22
//LIC// You should have received a copy of the GNU Lesser General Public
23
//LIC// License along with this library; if not, write to the Free Software
24
//LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
//LIC// 02110-1301 USA.
26
//LIC//
27
//LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28
//LIC//
29
//LIC//====================================================================
30
// Create an output file that can be read with geomview
31
// Change the infile name and the output name to use it
32
33
34
#include<iostream>
35
#include<fstream>
36
#include<vector>
37
#include<math.h>
38
using namespace
std
;
39
40
int
main
(
int
argc,
char
* argv[])
41
{
42
43
// Convert argument to strings that specify the input file name
44
string
mesh_file_name(argv[1]);
45
46
// Read the output mesh file to find informations about the nodes
47
// and elements of the mesh
48
49
ifstream infile(mesh_file_name.c_str(), ios_base::in);
50
unsigned
n_node;
51
infile>>n_node;
52
vector<double> x(n_node);
53
vector<double> y(n_node);
54
vector<int> vertinfo(n_node);
55
for
(
unsigned
i=0;i<n_node;i++)
56
{
57
infile>>x[i];
58
infile>>y[i];
59
infile>>vertinfo[i];
60
}
61
unsigned
n_vx;
62
infile>>n_vx;
63
vector<int> nodecode(n_vx);
64
vector<int> icurv(n_vx);
65
vector<double> ucurv(n_vx);
66
for
(
unsigned
i=0;i<n_vx;i++)
67
{
68
infile>>nodecode[i];
69
infile>>icurv[i];
70
infile>>ucurv[i];
71
}
72
unsigned
n_local_node;
73
infile>>n_local_node;
74
unsigned
n_element;
75
infile>>n_element;
76
unsigned
b=n_local_node*n_element;
77
vector<int> v(b);
78
vector<int> edgeinfo(b);
79
unsigned
k=0;
80
for
(
unsigned
i=0;i<n_element;i++)
81
{
82
for
(
unsigned
j=0;j<n_local_node;j++)
83
{
84
infile>>v[k];
85
k++;
86
}
87
}
88
unsigned
l=0;
89
for
(
unsigned
i=0;i<n_element;i++)
90
{
91
for
(
unsigned
j=0;j<n_local_node;j++)
92
{
93
infile>>edgeinfo[l];
94
l++;
95
}
96
}
97
98
infile.close();
99
100
// Create a file of type ".quad" to visualize the mesh with geomview
101
102
103
unsigned
nn=0;
104
char
result[20];
105
sprintf(result,
"%s"
,
"mesh.quad"
);
106
ofstream outfile(result,ios_base::out);
107
outfile<<
"QUAD"
<<
'\n'
;
108
for
(
unsigned
i=0;i<n_element;i++)
109
{
110
for
(
unsigned
j=0;j<n_local_node;j++)
111
{
112
outfile<<x[v[nn]-1]<<
" "
<<y[v[nn]-1]<<
" 0 "
;
113
nn++;
114
}
115
outfile<<
'\n'
;
116
}
117
outfile.close();
118
119
120
121
}
//end of main
std
main
int main(int argc, char *argv[])
Definition:
convert_geom_file.cc:40