00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __DOMAIN_H
00034 #define __DOMAIN_H
00035
00036 #include <stdlib.h>
00037 #include <math.h>
00038 #include <string>
00039 #include <stdio.h>
00040 #include <iostream>
00041 #include <fstream>
00042 #include <iomanip>
00043 #include <valarray>
00044 #include <vector>
00045
00046 using namespace std;
00047
00048
00049 #include "OFELI_Config.h"
00050 #include "util.h"
00051 #include "fparser.h"
00052 #include "FFI.h"
00053 #include "getMesh.h"
00054 #include "saveMesh.h"
00055 #include "misc/Mesh2.h"
00056 #include "misc/io.h"
00057 #include "misc/QuadTree.h"
00058 #include "misc/R2.h"
00059 #include "Point.h"
00060
00061 extern FunctionParser _theParser;
00062
00063 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00064 int bamg(const string &emfile, const string &outfile);
00065 #endif
00066
00067 namespace OFELI {
00068
00074 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00075 struct ErrorInDomain {
00076 void Message(const char *file, size_t line, int code, int p1=0, int p2=0);
00077 };
00078 #endif
00079
00089 class Domain
00090 {
00091
00092 struct Vertex : public Point<double> {
00093 double h;
00094 size_t label;
00095 int code;
00096 };
00097
00098 struct Ln {
00099 Ln() { s.resize(MAX_NB_LINE_NODES); node.resize(MAX_NB_LINE_NODES); }
00100 size_t nb, n1, n2;
00101 int Dcode, Ncode;
00102 valarray<double> s;
00103 valarray<Point<double> > node;
00104 };
00105
00106 typedef struct {
00107 size_t nb, first_line;
00108 int orientation[MAX_NB_CONT_LINES];
00109 size_t line[MAX_NB_CONT_LINES];
00110 } Cont;
00111
00112 typedef struct { int code, contour; } Sd;
00113 typedef struct { size_t i, j; int dc, nc; } LP;
00114 typedef struct { size_t n1, n2, n3, n4; int code; } El;
00115
00116 public:
00117
00118
00119
00122 Domain();
00123
00125 ~Domain()
00126 {
00127 #ifdef _OFELI_DEBUG
00128 std::clog << "An instance of class Domain is constructed.\n";
00129 std::clog << "File: " << __FILE__ << ", Line: " << __LINE__ << endl;
00130 #endif
00131 }
00132
00134 size_t getDim() const { return _dim; }
00135
00137 size_t getNbDOF() const { return _nb_dof; }
00138
00140 size_t getNbVertices() const { return _nb_vertices; }
00141
00143 size_t getNbLines() const { return _nb_lines; }
00144
00146 size_t getNbContours() const { return _nb_contours; }
00147
00149 size_t getNbHoles() const { return _nb_holes; }
00150
00152 size_t getNbSubDomains() const { return _nb_sub_domains; }
00153
00154 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00155 void Get() { get(); }
00156 void Get(const string &file) { get(file); }
00157 #endif
00158
00160 void get();
00161
00164 void get(const string &file);
00165
00168 int generateMesh(const string &file);
00169
00176 void insertVertex(double x, double y, double h, int code);
00177
00184 void insertLine(size_t n1, size_t n2, int dc, int nc);
00185
00198 void insertCircle(size_t n1, size_t n2, double cx, double cy, double r,
00199 double orient, size_t nb, int dc, int nc);
00200
00203 void insertContour(const vector<size_t> &c);
00204
00207 void insertHole(const vector<size_t> &c);
00208
00213 void insertSubDomain(size_t n, int code);
00214
00215 friend class XMLParser;
00216
00217 private:
00218
00219 FFI *_ff;
00220 ofstream *_jf;
00221 valarray<string> _kw;
00222 valarray<Vertex> _v, _V, _nd, _bnd;
00223 valarray<El> _el;
00224 valarray<Ln> _l;
00225 vector<Cont> _h;
00226 valarray<Sd> _sd;
00227 vector<Cont> _c;
00228 valarray<LP> _ln;
00229 size_t _v_label[MAX_NB_VERTICES], _l_label[MAX_NB_LINES], _h_label[MAX_NB_HOLES];
00230 size_t _dim, _nb_vertices, _nb_lines, _nb_contours, _nb_holes, _sub_domain, _nb_sub_domains;
00231 size_t _nb_dof;
00232 size_t _ret_cont, _ret_line, _ret_save, _ret_sd;
00233 bool _file;
00234 FILE *_mdf;
00235 ErrorInDomain _e;
00236
00237 void getVertex();
00238 int getLine();
00239 int getCurve();
00240 void getCircle();
00241 int getContour();
00242 int getHole();
00243 int getSubDomain();
00244 int Rectangle();
00245 int Disk();
00246 void deleteVertex();
00247 void deleteLine();
00248 void list();
00249 int saveAsEasymesh();
00250 int saveAsBamg();
00251 int saveAsTriangle();
00252 int Position(double s, double *data);
00253 int gm();
00254 int gm1(const string &file);
00255 int gm2(const string &file);
00256 int gm3(const string &file);
00257 int insert(size_t item, size_t &length, size_t *set);
00258 int remove(size_t item, size_t &length, size_t *set);
00259 void dof_code(int mark, valarray<int> &code);
00260 void dof_code(int mark, int *code);
00261 int zero_code(const valarray<int> &code);
00262 void init_kw();
00263 int setCode(size_t ne1, size_t ne2, size_t i, size_t j, size_t nb_dof,
00264 int c1, int c2, int c3, int c4);
00265 };
00266
00267 }
00268
00269 #endif