basis.cc
Go to the documentation of this file.
//
// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
//
// Rheolef is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Rheolef is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rheolef; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// =========================================================================
// the basis unix command
// author: Pierre.Saramito@imag.fr
// date: 11 september 2017
//
namespace rheolef {
} // namespace rheolef
#include "rheolef/basis.h"
#include "rheolef/basis_raw.h"
#include "rheolef/iorheo.h"
#include "rheolef/reference_element_face_transformation.h"
using namespace rheolef;
using namespace std;
void usage() {
cerr << "basis: usage:" << endl
<< "basis "
<< "[approx=P1] "
<< "[element=t] "
<< "{-dubiner|-monomial} "
<< "{-fem|-raw} "
<< "{-ndof|-poly|-node|-node-side int} "
<< "[-subdivide int] "
<< "[-[no]clean] [-[no]execute] [-[no]verbose] "
<< endl;
exit (1);
}
int main(int argc, char**argv) {
// --------------------------------
// scan command line
// --------------------------------
if (argc == 1) usage();
typedef enum {
show_poly = 0,
show_node = 1,
show_node_on_side = 2,
show_ndof = 3,
show_nnod = 4
} show_type;
show_type show = show_poly;
string approx = "P1";
char t = 't';
reference_element hat_K;
hat_K.set_name(t);
bool raw = false;
size_t nsub = 0;
side_information_type sid;
for (int i = 1; i < argc; i++) {
// general options:
if (strcmp (argv[i], "-clean") == 0) cout << clean;
else if (strcmp (argv[i], "-noclean") == 0) cout << noclean;
else if (strcmp (argv[i], "-execute") == 0) cout << execute;
else if (strcmp (argv[i], "-noexecute") == 0) cout << noexecute;
else if (strcmp (argv[i], "-verbose") == 0) cout << verbose;
else if (strcmp (argv[i], "-noverbose") == 0) cout << noverbose;
// basis options:
else if (strcmp (argv[i], "-fem") == 0) raw = false;
else if (strcmp (argv[i], "-raw") == 0) raw = true;
// view options:
else if (strcmp (argv[i], "-ndof") == 0) show = show_ndof;
else if (strcmp (argv[i], "-nnod") == 0) show = show_nnod;
else if (strcmp (argv[i], "-poly") == 0) show = show_poly;
else if (strcmp (argv[i], "-node") == 0) show = show_node;
else if (strcmp (argv[i], "-node-side") == 0) {
show = show_node_on_side;
if (i == argc-1) { cerr << "basis -node-side: option argument missing" << endl; usage(); }
sid.loc_isid = atoi(argv[++i]);
} else if (strcmp (argv[i], "-subdivide") == 0) {
if (i == argc-1) { cerr << "basis -subdivide: option argument missing" << endl; usage(); }
nsub = atoi(argv[++i]);
cout << setsubdivide (nsub);
// reference element spec:
} else if (argv[i][0] != '-' && strlen(argv[i]) == 1) {
t = argv[i][0];
hat_K.set_name(t);
// basis spec:
} else if (argv[i][0] != '-' && strlen(argv[i]) >= 2) {
approx = argv[i];
} else {
cerr << "unexpected option `" << argv[i]<< endl;
usage();
}
}
if (approx[0] == 'M' || approx[0] == 'D') {
raw = true;
}
if (nsub == 0) {
nsub = (hat_K.dimension() == 1) ? 1000 : 40;
cout << setsubdivide (nsub);
}
// --------------------------------
// show
// --------------------------------
if (raw) { // raw basis
if (show != show_poly) {
cerr << "basis: raw basis no not have nodes (HINT: use -poly option instead of -node)" << endl;
exit (1);
}
basis_raw b (approx);
b.put (cout, hat_K);
return 0;
}
// fem basis
basis b (approx);
switch (show) {
case show_ndof:
cout << b.ndof (hat_K) << endl;
break;
case show_nnod:
cout << b.nnod (hat_K) << endl;
break;
case show_poly:
b.put (cout, hat_K);
break;
case show_node:
b.put_hat_node (cout, hat_K);
break;
case show_node_on_side:
b.put_hat_node_on_side (cout, hat_K, sid);
break;
}
}
usage
void usage()
Definition: basis.cc:157
main
int main(int argc, char **argv)
Definition: basis.cc:170
show_type
show_type
Definition: field.cc:402
basis
see the basis page for the full documentation
rheolef::reference_element
see the reference_element page for the full documentation
Definition: reference_element.h:66
rheolef::reference_element::set_name
void set_name(char name)
Definition: reference_element.cc:59
rheolef::reference_element::dimension
size_type dimension() const
Definition: reference_element.h:101
rheolef::std
Definition: vec_expr_v2.h:402
rheolef::basis_raw
basis_raw_basic< Float > basis_raw
Definition: basis_raw.h:155
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
mkgeo_ball.clean
clean
Definition: mkgeo_ball.sh:335
mkgeo_ball.verbose
verbose
Definition: mkgeo_ball.sh:133
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::side_information_type
Definition: reference_element_face_transformation.h:37
rheolef::side_information_type::loc_isid
size_t loc_isid
Definition: reference_element_face_transformation.h:38