3
# This file is part of Rheolef.
5
# Copyright (C) 2000-2009 Pierre Saramito
7
# Rheolef is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# Rheolef is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Rheolef; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
# -------------------------------------------------------------------------
24
#NAME: @code{mkgeo_grid} -- build a strutured mesh of a parallelotope, in 1d, 2d or 3d
28
#@fiindex @file{.geo} mesh
31
# mkgeo_grid @var{options} [@var{nx} [@var{ny} [@var{nz}]]]
35
# The following command build a triangular based 2d 10x10 grid
38
# mkgeo_grid -t 10 > square-10.geo
42
# or in one comand line:
44
# mkgeo_grid -t 10 | geo -
48
# This command is usefull when testing programs on simple geometries.
49
# It avoid the preparation of an input file for a mesh generator.
50
# The optional @var{nx}, @var{ny} and @var{nz} arguments are integer
51
# that specifies the subdivision in each direction. By default
52
# @var{nx}=10, @var{ny}=@var{nx} and @var{nz}=@var{ny}.
53
# The mesh files goes on standard output.
56
# The command supports all the possible element types: edges, triangles,
57
# rectangles, tetraedra, prisms and hexahedra.
58
#ELEMENT TYPE OPTIONS:
61
# 1d mesh using edges.
63
# 2d mesh using triangles.
65
# 2d mesh using quadrangles (rectangles).
67
# 3d mesh using tetraedra.
69
# 3d mesh using prisms.
71
# 3d mesh using hexahedra.
75
# The geometry can be any [a,b] segment, [a,b]x[c,d] rectangle
76
# or [a,b]x[c,d]x[f,g] parallelotope. By default a=c=f=0 and b=d=g=1, thus,
77
# the unit boxes are considered. For instance, the following
78
# command meshes the [-2,2]x[-1.5, 1.5] rectangle:
80
# mkgeo_grid -t 10 -a -2 -b 2 -c -1.5 -d 1.5 | geo -
83
#@itemx -a @var{float}
84
#@itemx -b @var{float}
85
#@itemx -c @var{float}
86
#@itemx -d @var{float}
87
#@itemx -f @var{float}
88
#@itemx -g @var{float}
94
# The boundary sides are representd by domains: @code{left}, @code{right},
95
# @code{top}, @code{bottom},@code{front} and @code{back}.
98
# This option defines a domain named @code{boundary} that groups all sides.
100
#By default, both sides and the whole boundary are defined as domains:
102
# mkgeo_grid -t 10 > square.geo
104
# mkgeo_grid -t 10 -nosides > square.geo
106
# mkgeo_grid -t 10 -noboundary > square.geo
108
# mkgeo_grid -t 10 -noboundary -nosides > square.geo
115
# The whole domain is splitted into two subdomains: @code{east} and @code{west},
116
# This option is used for testing computations with subdomains (e.g. transmission
117
# problem; see the user manual).
120
# mkgeo_grid -t 10 -region | geo -
126
# The corners (four in 2D and eight in 3D) are defined as OD-domains.
127
# This could be usefull for some special boundary conditions.
130
# mkgeo_grid -t 10 -corner | geo -
131
# mkgeo_grid -T 5 -corner | geo -
134
#COORDINATE SYSTEM OPTION:
135
# Most of rheolef codes are coordinate-system independant.
136
# The coordinate system is specified in the geometry file @file{.geo}.
138
#@cindex axisymmetric coordinate system
141
# the 2d mesh is axisymmetric: @code{zr} (resp. @code{rz}) stands when the symmetry is related
142
# to the first (resp. second) coordinate.
165
if test $# -eq 0; then
172
sys_coord="cartesian"
173
new_format=`rheolef-config --is-distributed 2>/dev/null`
174
GEO_BIN=${GEO_BIN-"geo"}
175
while test $# -ne 0; do
177
-h) echo ${usage} >&2; exit 0;;
178
-e) dim="1d"; args="$args $1";;
179
-[tq]) dim="2d"; args="$args $1";;
180
-[TPH]) dim="3d"; args="$args $1";;
181
[\-\+0-9e]*) args="$args $1";;
182
-[abcdfg]) args="$args $1 $2"; shift;;
183
-rz) args="$args $1"; sys_coord="rz";;
184
-zr) args="$args $1"; sys_coord="zr";;
185
-sides | -boundary | -region | -corner | -nosides | -noboundary | -noregion | -nocorner)
187
*) echo ${usage} >&2; exit 1;;
191
if test ${new_format} = true; then
194
#echo "! GEO_BIN=${GEO_BIN}" >&2
195
#echo "! new_format=${new_format}" >&2
196
pkgbindir=`rheolef-config --pkglibdir`
198
if test $sys_coord != "cartesian" -a $dim != 2d; then
199
echo "mkgeo_grid: incompatible $dim geometry and non-cartesian \"${sys_coord}\"coordinate system" >&2
203
command="$pkgbindir/mkgeo_grid_$dim $args 2>/dev/null"
204
if test $dim = 3d || test ${new_format} = true; then
205
command="$command | ${GEO_BIN} -upgrade -geo - 2>/dev/null"
207
#echo "! $command" >&2
210
if test $status -ne 0; then
211
echo "$0: command failed" 1>&2