Skip to content
Snippets Groups Projects
Commit feb0376e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

cleanup

parent aca90843
No related branches found
No related tags found
No related merge requests found
# Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file for license information. Please report all
# bugs and problems to <gmsh@geuz.org>.
include ../../variables
mshsort: mshsort.cpp
${CXX} ${OPTIM} -o ../../bin/mshsort mshsort.cpp
clean:
rm -f *.o *.exe mshsort
depend:
true
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
int main(void)
{
int i, pid;
FILE *fp;
for(i = 0; i < 5; i++){
system("gmsh -pid fichier.msh fichier.pos > /tmp/gmsh.pid &");
printf("computing %d...\n", i);
sleep(2);
fp = fopen("/tmp/gmsh.pid", "r");
fscanf(fp, "%d", &pid);
fclose(fp);
kill(pid, 9);
}
}
...@@ -14,12 +14,10 @@ Requires: Mesa >= 3.2 ...@@ -14,12 +14,10 @@ Requires: Mesa >= 3.2
Prefix: /usr Prefix: /usr
%description %description
Gmsh is an automatic three-dimensional finite element mesh generator, Gmsh is an automatic three-dimensional finite element mesh generator
primarily Delaunay, with built-in pre- and post-processing with built-in pre- and post-processing facilities. Its primal design
facilities. Its primal design goal is to provide a simple meshing tool goal is to provide a simple meshing tool for academic test cases with
for academic test cases with parametric input and up to date parametric input and up to date visualization capabilities.
visualization capabilities. Gmsh requires OpenGL (or Mesa) to be
installed on your system.
Install Gmsh if you need a simple 3D finite element mesh generator Install Gmsh if you need a simple 3D finite element mesh generator
and/or post-processor. and/or post-processor.
...@@ -30,7 +28,6 @@ and/or post-processor. ...@@ -30,7 +28,6 @@ and/or post-processor.
%build %build
make distrib-unix make distrib-unix
make utils
make doc-info make doc-info
strip bin/gmsh strip bin/gmsh
rm -rf CVS */CVS */*/CVS rm -rf CVS */CVS */*/CVS
...@@ -42,8 +39,6 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1 ...@@ -42,8 +39,6 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
mkdir -p $RPM_BUILD_ROOT/usr/share/info mkdir -p $RPM_BUILD_ROOT/usr/share/info
install -m 755 bin/gmsh $RPM_BUILD_ROOT/usr/bin/gmsh install -m 755 bin/gmsh $RPM_BUILD_ROOT/usr/bin/gmsh
install -m 755 bin/dxf2geo $RPM_BUILD_ROOT/usr/bin/dxf2geo
install -m 755 bin/mshsort $RPM_BUILD_ROOT/usr/bin/mshsort
install -m 644 doc/gmsh.1 $RPM_BUILD_ROOT/usr/share/man/man1/gmsh.1 install -m 644 doc/gmsh.1 $RPM_BUILD_ROOT/usr/share/man/man1/gmsh.1
install -m 644 doc/texinfo/gmsh.info* $RPM_BUILD_ROOT/usr/share/info/ install -m 644 doc/texinfo/gmsh.info* $RPM_BUILD_ROOT/usr/share/info/
...@@ -55,9 +50,7 @@ rm -rf $RPM_BUILD_ROOT ...@@ -55,9 +50,7 @@ rm -rf $RPM_BUILD_ROOT
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%doc doc/LICENSE doc/VERSIONS doc/FAQ doc/CREDITS demos tutorial %doc doc/LICENSE.txt doc/VERSIONS.txt doc/FAQ.txt doc/CREDITS.txt demos tutorial
/usr/bin/gmsh /usr/bin/gmsh
/usr/bin/dxf2geo
/usr/bin/mshsort
/usr/share/man/man1/gmsh* /usr/share/man/man1/gmsh*
/usr/share/info/gmsh* /usr/share/info/gmsh*
#!/bin/sh
SRCDIR=gmsh-distrib
DMGNAME=gmsh.dmg
VOLNAME=gmsh
####################################################################
###### 1. create a disk image and format it
####################################################################
# compute total size of disk image (5% percent more than the
# total data size; this allows for the partition tables overhead:
# 64 sectors, 512 bytes each + some spare)
#
SIZE=`du -sk ${SRCDIR} | awk '{printf "%.3gn",($1*10.5)/(10240)}'`
# create the disk image
#
hdiutil create tmp.dmg -megabytes ${SIZE} -ov -type UDIF
# create /dev entries but do not mount it, else the Finder will prompt
# to initialize the disk (since the disk is not formatted yet)
#
# The output of hdid looks like
#
# /dev/disk2 Apple_partition_scheme
# /dev/disk2s1 Apple_partition_map
# /dev/disk2s2 Apple_HFS
#
# MYDISK contains only the disk name, i.e. "disk2"
#
# To check to currently handled disks images, type
#
# hdiutils info
#
MYDISK=`hdid -nomount tmp.dmg |awk '/scheme/ {print substr ($1, 6, length)}'`
# make a new filesystem on the device
#
sudo newfs_hfs -v "$VOLNAME" /dev/r${MYDISK}s2
# eject the device
#
hdiutil eject $MYDISK
####################################################################
###### 2. mount the disk image and copy files to it
####################################################################
# mount the image
#
hdid tmp.dmg
# make sure that there are no locked files before running ditto
# (ditto is the same as 'cp', except that it preserves resource
# forks)
#
chflags -R nouchg,noschg "${SRCDIR}"
ditto -rsrcFork -v "${SRCDIR}" "/Volumes/${VOLNAME}"
# eject the device
#
hdiutil eject $MYDISK
####################################################################
###### 3. Convert to compressed image, delete temp image
####################################################################
# convert to compressed image
#
hdiutil convert tmp.dmg -format UDZO -o "${DMGNAME}"
# remove temp image
#
rm -f tmp.dmg
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
// A small utility that reads a Gmsh mesh file and makes the numbering
// dense (without gaps in the node/element number sequences)
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
using namespace std;
int getNumNodes(int type)
{
switch (type) {
case 15: return 1; // point
case 1 : return 2; // line 1
case 8 : return 2 + 1; // line 2
case 2 : return 3; // triangle 1
case 9 : return 3 + 3; // triangle 2
case 3 : return 4; // quadrangle 1
case 10: return 4 + 4 + 1; // quadrangle 2
case 4 : return 4; // tetrahedron 1
case 11: return 4 + 6; // tetrahedron 2
case 5 : return 8; // hexahedron 1
case 12: return 8 + 12 + 6 + 1; // hexahedron 2
case 6 : return 6; // prism 1
case 13: return 6 + 9 + 3; // prism 2
case 7 : return 5; // pyramid 1
case 14: return 5 + 8 + 1; // pyramid 2
default: return 0;
}
}
class node{
private:
int _num;
double _x, _y, _z;
public:
node(double x, double y, double z)
: _num(0), _x(x), _y(y), _z(z) {}
void setNum(int num){ _num = num; }
int getNum(){ return _num; }
void print(FILE *fp, double version){
fprintf(fp, "%d %.16g %.16g %.16g\n", _num, _x, _y, _z);
}
};
class element{
private:
int _num, _type, _physical, _elementary, _partition;
vector<node*> _nodes;
public:
element(int type, int physical, int elementary, int partition)
: _num(0), _type(type), _physical(physical), _elementary(elementary),
_partition(partition) {}
void setNum(int num){ _num = num; }
void addNode(node *n){ _nodes.push_back(n); }
void print(FILE *fp, double version){
if(version == 2.0)
fprintf(fp, "%d %d 3 %d %d %d", _num, _type, _physical,
_elementary, _partition);
else
fprintf(fp, "%d %d %d %d %d", _num, _type, _physical,
_elementary, (int)_nodes.size());
for(unsigned int i = 0; i < _nodes.size(); i++)
fprintf(fp, " %d", _nodes[i]->getNum());
fprintf(fp, "\n");
}
};
double readMesh(FILE *fp, map<int, node*> &nodes, vector<element*> &elements)
{
double version = 1.0;
while(1) {
char str[256];
do {
fgets(str, sizeof(str), fp);
if(feof(fp))
break;
} while(str[0] != '$');
if(feof(fp))
break;
if(!strncmp(&str[1], "MeshFormat", 10)) {
int format, size;
fscanf(fp, "%lf %d %d\n", &version, &format, &size);
if(version != 2.0){
fprintf(stderr, "Error: Wrong msh file version %g\n", version);
exit(1);
}
if(format){
fprintf(stderr, "Error: Unknown data format for mesh\n");
exit(1);
}
}
else if(!strncmp(&str[1], "NOD", 3) ||
!strncmp(&str[1], "NOE", 3) ||
!strncmp(&str[1], "Nodes", 5)) {
int numNodes;
fscanf(fp, "%d", &numNodes);
for(int i = 0; i < numNodes; i++) {
int num;
double x, y, z;
fscanf(fp, "%d %lf %lf %lf", &num, &x, &y, &z);
if(nodes.count(num)){
fprintf(stderr, "Error: node %d already exists\n", num);
exit(1);
}
else
nodes[num] = new node(x, y, z);
}
}
else if(!strncmp(&str[1], "ELM", 3) ||
!strncmp(&str[1], "Elements", 8)) {
int numElements;
fscanf(fp, "%d", &numElements);
for(int i = 0; i < numElements; i++) {
int num, type, physical, elementary, partition = 1, numNodes, numTags;
if(version <= 1.0){
fscanf(fp, "%d %d %d %d %d",
&num, &type, &physical, &elementary, &numNodes);
int numNodesCheck = getNumNodes(type);
if(!numNodesCheck){
fprintf(stderr, "Error: Unknown type %d for element %d\n", type, num);
exit(1);
}
if(numNodes != numNodesCheck){
fprintf(stderr, "Error: Wrong number of nodes for element %d\n", num);
exit(1);
}
}
else{
fscanf(fp, "%d %d %d", &num, &type, &numTags);
elementary = physical = partition = 1;
for(int j = 0; j < numTags; j++){
int tag;
fscanf(fp, "%d", &tag);
if(j == 0)
physical = tag;
else if(j == 1)
elementary = tag;
else if(j == 2)
partition = tag;
// ignore any other tags for now
}
numNodes = getNumNodes(type);
if(!numNodes){
fprintf(stderr, "Error: Unknown type %d for element %d\n", type, num);
exit(1);
}
}
element *e = new element(type, physical, elementary, partition);
for(int j = 0; j < numNodes; j++){
int numNode;
fscanf(fp, "%d", &numNode);
if(nodes.count(numNode))
e->addNode(nodes[numNode]);
else{
fprintf(stderr, "Error: Unknown vertex %d in element %d\n", numNode, num);
exit(1);
}
}
elements.push_back(e);
}
}
do {
fgets(str, sizeof(str), fp);
if(feof(fp)){
fprintf(stderr, "Error: Prematured end of mesh file\n");
exit(1);
}
} while(str[0] != '$');
}
fclose(fp);
return version;
}
void printMesh(FILE *fp, double version, map<int, node*> nodes, vector<element*> elements,
int nodeStartIndex=1, int elementStartIndex=1)
{
map<int, node*>::const_iterator it = nodes.begin();
map<int, node*>::const_iterator ite = nodes.end();
if(version == 2.0){
fprintf(fp, "$MeshFormat\n");
fprintf(fp, "2.0 0 %d\n", (int)sizeof(double));
fprintf(fp, "$EndMeshFormat\n");
fprintf(fp, "$Nodes\n");
}
else
fprintf(fp, "$NOD\n");
fprintf(fp, "%d\n", (int)nodes.size());
for(;it!=ite;++it){
it->second->setNum(nodeStartIndex++);
it->second->print(fp, version);
}
if(version == 2.0){
fprintf(fp, "$EndNodes\n");
fprintf(fp, "$Elements\n");
}
else{
fprintf(fp, "$ENDNOD\n");
fprintf(fp, "$ELM\n");
}
fprintf(fp, "%d\n", (int)elements.size());
for(unsigned int i = 0; i < elements.size(); i++){
elements[i]->setNum(elementStartIndex++);
elements[i]->print(fp, version);
}
if(version == 2.0)
fprintf(fp, "$EndElements\n");
else
fprintf(fp, "$ENDELM\n");
}
int main(int argc, char **argv)
{
if(argc < 2){
fprintf(stderr, "mshsort, a utility to reorder the node and element lists in Gmsh MSH files\n");
fprintf(stderr, "Usage: %s in.msh [out.msh] [node_start_index] [element_start_index]\n",
argv[0]);
exit(1);
}
FILE *in, *out;
if(!(in = fopen(argv[1], "r"))){
fprintf(stderr, "Error: Unable to open input file '%s'\n", argv[1]);
exit(1);
}
if(argc >= 3){
if(!(out = fopen(argv[2], "w"))){
fprintf(stderr, "Error: Unable to open output file '%s'\n", argv[2]);
exit(1);
}
}
else{
out = stdout;
}
int nodeStartIndex = (argc >= 4) ? atoi(argv[3]) : 1;
int elementStartIndex = (argc >= 5) ? atoi(argv[4]) : 1;
map<int, node*> nodes;
vector<element*> elements;
double version = readMesh(in, nodes, elements);
printMesh(out, version, nodes, elements, nodeStartIndex, elementStartIndex);
}
#!/bin/sh
if [ $# -lt 2 ]; then
echo "Usage: $0 path program [options]" 1>&2;
exit 1;
fi
path=$1
shift 1
program=$*
files=`find $path -name "*.geo"`
for file in $files ; do
echo "Running $program $file" ;
$program $file -o /tmp/tmp.msh >& log ;
grep -i "Warning" log ;
grep -i "Error" log ;
done
// Gmsh project created on Thu Mar 26 10:01:45 2009
m=0.5;
Point(newp) = {0, 0, 0, m};
Point(newp) = {10, 0, 0, m};
Point(newp) = {10, 10, 0, m};
Point(newp) = {0, 10, 0, m};
Point(newp) = {4, 4, 0, m};
Point(newp) = {6, 4, 0, m};
Point(newp) = {6, 6, 0, m};
Point(newp) = {4, 6, 0, m};
Point(newp) = {2, 0, 0, m};
Point(newp) = {8, 0, 0, m};
Point(newp) = {2, 10, 0, m};
Point(newp) = {8, 10, 0, m};
Point(newp) = {0, 0, 1, m};
Point(newp) = {10, 0, 1, m};
Point(newp) = {10, 10, 1, m};
Point(newp) = {0, 10, 1, m};
Point(newp) = {4, 4, 1, m};
Point(newp) = {6, 4, 1, m};
Point(newp) = {6, 6, 1, m};
Point(newp) = {4, 6, 1, m};
Point(newp) = {2, 0, 1, m};
Point(newp) = {8, 0, 1, m};
Point(newp) = {2, 10, 1, m};
Point(newp) = {8, 10, 1, m};
Line(1) = {16, 23};
Line(2) = {23, 11};
Line(3) = {11, 4};
Line(4) = {4, 16};
Line(5) = {24, 12};
Line(6) = {12, 3};
Line(7) = {3, 15};
Line(8) = {15, 24};
Line(9) = {10, 2};
Line(10) = {2, 14};
Line(11) = {14, 22};
Line(12) = {22, 10};
Line(13) = {21, 9};
Line(14) = {9, 1};
Line(15) = {1, 13};
Line(16) = {13, 21};
Line Loop(17) = {3, 4, 1, 2};
Ruled Surface(18) = {17};
Line Loop(19) = {6, 7, 8, 5};
Ruled Surface(20) = {19};
Line Loop(21) = {9, 10, 11, 12};
Ruled Surface(22) = {21};
Line Loop(23) = {14, 15, 16, 13};
Ruled Surface(24) = {23};
Line(25) = {16, 13};
Line(26) = {1, 4};
Line(27) = {11, 12};
Line(28) = {24, 23};
Line(29) = {21, 22};
Line(30) = {10, 9};
Line(31) = {2, 3};
Line(32) = {15, 14};
Line(33) = {20, 19};
Line(34) = {19, 18};
Line(35) = {18, 17};
Line(36) = {17, 20};
Line(37) = {8, 7};
Line(38) = {7, 6};
Line(39) = {6, 18};
Line(40) = {5, 6};
Line(41) = {5, 8};
Line(42) = {20, 8};
Line(43) = {17, 5};
Line(44) = {19, 7};
Line Loop(45) = {27, -5, 28, 2};
Ruled Surface(46) = {45};
Line Loop(47) = {25, -15, 26, 4};
Ruled Surface(48) = {47};
Line Loop(49) = {29, 12, 30, -13};
Ruled Surface(50) = {49};
Line Loop(51) = {32, -10, 31, 7};
Ruled Surface(52) = {51};
Line Loop(53) = {41, -42, -36, 43};
Ruled Surface(54) = {53};
Line Loop(55) = {35, 43, 40, 39};
Ruled Surface(56) = {55};
Line Loop(57) = {34, -39, -38, -44};
Ruled Surface(58) = {57};
Line Loop(59) = {33, 44, -37, -42};
Ruled Surface(60) = {59};
Line Loop(61) = {27, 6, -31, -9, 30, 14, 26, -3};
Line Loop(62) = {37, 38, -40, 41};
Plane Surface(63) = {61, 62};
Line Loop(64) = {25, 16, 29, -11, -32, 8, 28, -1};
Line Loop(65) = {34, 35, 36, 33};
Plane Surface(66) = {64, 65};
Surface Loop(67) = {66, 48, 24, 63, 46, 20, 52, 22, 50, 18, 54, 60, 58, 56};
Volume(68) = {67};
#!/bin/sh
enscript -t "Gmsh tutorial" -Ecpp --color -Whtml --toc -pt.html README *.geo
cat t.html | \
sed "s/<FONT COLOR=\"#BC8F8F\"><B>//g" | \
sed "s/<B><FONT COLOR=\"#5F9EA0\">//g" | \
sed "s/<B><FONT COLOR=\"#A020F0\">//g" | \
sed "s/<B><FONT COLOR=\"#0000FF\">//g" | \
sed "s/<\/FONT><\/B>//g" > tutorial.html
rm -f t.html
echo output moved to tutorial.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment