Rheolef  7.2
an efficient C++ finite element environment
basis.cc
Go to the documentation of this file.
1 //
4 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
5 //
6 // Rheolef is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // Rheolef is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Rheolef; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // =========================================================================
21 // the basis unix command
22 // author: Pierre.Saramito@imag.fr
23 // date: 11 september 2017
24 //
25 
26 namespace rheolef {
149 } // namespace rheolef
150 
151 #include "rheolef/basis.h"
152 #include "rheolef/basis_raw.h"
153 #include "rheolef/iorheo.h"
154 #include "rheolef/reference_element_face_transformation.h"
155 using namespace rheolef;
156 using namespace std;
157 
158 void usage() {
159  cerr << "basis: usage:" << endl
160  << "basis "
161  << "[approx=P1] "
162  << "[element=t] "
163  << "{-dubiner|-monomial} "
164  << "{-fem|-raw} "
165  << "{-ndof|-poly|-node|-node-side int} "
166  << "[-subdivide int] "
167  << "[-[no]clean] [-[no]execute] [-[no]verbose] "
168  << endl;
169  exit (1);
170 }
171 int main(int argc, char**argv) {
172  // --------------------------------
173  // scan command line
174  // --------------------------------
175  if (argc == 1) usage();
176  typedef enum {
177  show_poly = 0,
178  show_node = 1,
179  show_node_on_side = 2,
180  show_ndof = 3,
181  show_nnod = 4
182  } show_type;
183  show_type show = show_poly;
184  string approx = "P1";
185  char t = 't';
186  reference_element hat_K;
187  hat_K.set_name(t);
188  bool raw = false;
189  size_t nsub = 0;
191  for (int i = 1; i < argc; i++) {
192 
193  // general options:
194  if (strcmp (argv[i], "-clean") == 0) cout << clean;
195  else if (strcmp (argv[i], "-noclean") == 0) cout << noclean;
196  else if (strcmp (argv[i], "-execute") == 0) cout << execute;
197  else if (strcmp (argv[i], "-noexecute") == 0) cout << noexecute;
198  else if (strcmp (argv[i], "-verbose") == 0) cout << verbose;
199  else if (strcmp (argv[i], "-noverbose") == 0) cout << noverbose;
200 
201  // basis options:
202  else if (strcmp (argv[i], "-fem") == 0) raw = false;
203  else if (strcmp (argv[i], "-raw") == 0) raw = true;
204 
205  // view options:
206  else if (strcmp (argv[i], "-ndof") == 0) show = show_ndof;
207  else if (strcmp (argv[i], "-nnod") == 0) show = show_nnod;
208  else if (strcmp (argv[i], "-poly") == 0) show = show_poly;
209  else if (strcmp (argv[i], "-node") == 0) show = show_node;
210  else if (strcmp (argv[i], "-node-side") == 0) {
211  show = show_node_on_side;
212  if (i == argc-1) { cerr << "basis -node-side: option argument missing" << endl; usage(); }
213  sid.loc_isid = atoi(argv[++i]);
214  } else if (strcmp (argv[i], "-subdivide") == 0) {
215  if (i == argc-1) { cerr << "basis -subdivide: option argument missing" << endl; usage(); }
216  nsub = atoi(argv[++i]);
217  cout << setsubdivide (nsub);
218 
219  // reference element spec:
220  } else if (argv[i][0] != '-' && strlen(argv[i]) == 1) {
221  t = argv[i][0];
222  hat_K.set_name(t);
223  // basis spec:
224  } else if (argv[i][0] != '-' && strlen(argv[i]) >= 2) {
225  approx = argv[i];
226  } else {
227  cerr << "unexpected option `" << argv[i]<< endl;
228  usage();
229  }
230  }
231  if (approx[0] == 'M' || approx[0] == 'D') {
232  raw = true;
233  }
234  if (nsub == 0) {
235  nsub = (hat_K.dimension() == 1) ? 1000 : 40;
236  cout << setsubdivide (nsub);
237  }
238  // --------------------------------
239  // show
240  // --------------------------------
241  if (raw) { // raw basis
242  if (show != show_poly) {
243  cerr << "basis: raw basis no not have nodes (HINT: use -poly option instead of -node)" << endl;
244  exit (1);
245  }
246  basis_raw b (approx);
247  b.put (cout, hat_K);
248  return 0;
249  }
250  // fem basis
251  basis b (approx);
252  switch (show) {
253  case show_ndof:
254  cout << b.ndof (hat_K) << endl;
255  break;
256  case show_nnod:
257  cout << b.nnod (hat_K) << endl;
258  break;
259  case show_poly:
260  b.put (cout, hat_K);
261  break;
262  case show_node:
263  b.put_hat_node (cout, hat_K);
264  break;
265  case show_node_on_side:
266  b.put_hat_node_on_side (cout, hat_K, sid);
267  break;
268  }
269 }
void usage()
Definition: basis.cc:158
int main(int argc, char **argv)
Definition: basis.cc:171
show_type
Definition: field.cc:402
see the basis page for the full documentation
see the reference_element page for the full documentation
rheolef::space_base_rep< T, M > t
basis_raw_basic< Float > basis_raw
Definition: basis_raw.h:155
This file is part of Rheolef.