Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
field2bb.cc
Go to the documentation of this file.
1
21//
22// Passage du format field au format bb de Bamg
23//
24// author: Pierre.Saramito@imag.fr
25//
26// date: 03/09/1997 ; 04/01/2018
27//
28/*Prog:field2bb
29NAME: @code{field2bb} - convert from .field file format to bamg .bb one
30@pindex field2bb
31@fiindex @file{.bb} bamg field
32@fiindex @file{.field} field
33@toindex @code{bamg}
34SYNOPSIS:
35@example
36 field2bb < @var{input}.field > @var{output}.bb
37@end example
38
39DESCRIPTION:
40 Convert a @file{.field} file into a bamg @file{.bb} one.
41 The output goes to standart output.
42 This command is useful for mesh adaptation with @code{bamg}.
43
44LIMITATION:
45 Do not support yet tensor valued .field files.
46 This could be interessant for specifying directly
47 a metric for mesh adaptation.
48End:*/
49#include "scatch.icc"
50#include <iostream>
51#include <iomanip>
52#include <string>
53#include <vector>
54#include <limits>
55using namespace std;
56using namespace rheolef;
57
58int main()
59{
60 // Lecture du fichier field
61 //-------------------------
62 scatch (cin, "field", true);
63 string ch1;
64 cin >> ch1;// version
65 size_t version = atoi(ch1.c_str());
66 if (version != 1) {
67 cerr << "field2bb: version " << version << " field format not yet supported" << endl;
68 exit (1);
69 }
70 cin >> ch1;
71 size_t nbpts = atoi(ch1.c_str());
72 cin >> ch1 // mesh name
73 >> ch1; // approx
74 if (ch1 != "P1") {
75 cerr << "field2bb: approx " << ch1 << " field not yet supported" << endl;
76 exit (1);
77 }
78 vector<double> u (nbpts);
79 for (size_t i=0; i<nbpts; i++) {
80 cin >> ch1;
81 u[i] = atof(ch1.c_str());
82 }
83 // Ecriture sur le fichier bb
84 //---------------------------
85 cout << setprecision(numeric_limits<double>::digits10)
86 << "2 1 " << nbpts << " 2" << endl;
87 for (size_t i=0; i<nbpts; i++) {
88 cout << u[i] << endl;
89 }
90}
int main()
Definition field2bb.cc:58
This file is part of Rheolef.
bool scatch(std::istream &in, const std::string &ch, bool full_match=true)
scatch: see the rheostream page for the full documentation
Definition scatch.icc:44
STL namespace.
Definition leveque.h:25