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
00034 #ifndef __SIDE_H
00035 #define __SIDE_H
00036
00037 #include <stdlib.h>
00038
00039 #include <valarray>
00040 using std::valarray;
00041
00042 #include <string>
00043 using std::string;
00044
00045 #include "OFELI_Config.h"
00046 #include "Node.h"
00047 #include "output.h"
00048
00049 namespace OFELI {
00050
00059 enum BCType {
00060 PERIODIC_A = 9999,
00061 PERIODIC_B = -9999,
00062 CONTACT = 9998,
00063 CONTACT_M = 9997,
00064 CONTACT_S = -9997,
00065 SLIP = 9996
00066 };
00067
00068 class Element;
00069
00070 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00071 struct ErrorInSide {
00072 void Message(const char *file, size_t line, int code, int p1=0) const;
00073 };
00074 #endif
00075
00076
00089 class Side
00090 {
00091
00092 public:
00093
00097 enum SideType {
00098 INTERNAL_SIDE = 0,
00099 EXTERNAL_BOUNDARY = 1,
00100 INTERNAL_BOUNDARY = 2
00101 };
00102
00103
00104
00106 Side();
00107
00112 Side(size_t label, const string &shape);
00113
00118 Side(size_t label, int shape);
00119
00121 Side(const Side &sd);
00122
00124 ~Side() {
00125 #ifdef _OFELI_DEBUG
00126 std::clog << "An instance of class Side is destructed.\n";
00127 std::clog << "File : " << __FILE__ << ", Line : " << __LINE__ << endl;
00128 #endif
00129 }
00130
00131
00132
00134 void Add(Node *node);
00135
00137 void setLabel(size_t i) { _label = i; }
00138
00140 void setFirstDOF(size_t n) { _first_dof = n; }
00141
00143 void setNbDOF(size_t nb_dof) { _nb_dof = nb_dof; }
00144
00149 void DOF(size_t i, size_t dof) { _dof[i-1] = dof; }
00150
00155 void setDOF(size_t &first_dof, size_t nb_dof);
00156
00158 void setCode(size_t dof, int code) { _code[dof-1] = code; }
00159
00161 void Replace(size_t label, Node *node);
00162
00164 void AddNeighbor(Element *el) { if (el) _el[_neig_el++] = el; }
00165
00167 void setNode(size_t i, Node *node);
00168
00169
00170
00172 int getShape() const { return _shape; }
00173
00175 size_t getLabel() const { return _label; }
00176
00178 size_t getNbNodes() const { return _nb_nodes; }
00179
00181 size_t getNbVertices() const;
00182
00184 size_t getNbEq() const { return _nb_eq; }
00185
00187 size_t getNbDOF() const { return _nb_dof; }
00188
00190 int getCode(size_t dof) const { return _code[dof-1]; }
00191
00193 size_t getDOF(size_t i) const { return _dof[i-1]; }
00194
00196 size_t getFirstDOF() const { return _first_dof; }
00197
00199 Node *getPtrNode(size_t i) const { return _node[i-1]; }
00200
00202 size_t getNodeLabel(size_t i) const { return _node[i-1]->getLabel(); }
00203
00205 Element *getNeighborElement(size_t i) const { return _el[i-1]; }
00206
00214 int isOnBoundary() const;
00215
00217 void setOnBoundary();
00218
00224 double getMeasure() const;
00225
00227 Node *operator()(size_t i) const { return getPtrNode(i); }
00228
00229 friend class Mesh;
00230 friend void Refine(Mesh &in_mesh, Mesh &out_mesh);
00231 friend ostream& operator<<(ostream& s, const Mesh &ms);
00232
00233 private:
00234
00235 valarray<int> _code;
00236 valarray<size_t> _dof;
00237 mutable int _on_boundary;
00238 size_t _nb_dof, _label, _nb_nodes, _nb_eq, _first_dof, _neig_el;
00239 int _shape;
00240 Node *_node[MAX_NB_SIDE_NODES];
00241 Element *_el[2];
00242 bool _alive;
00243 ErrorInSide _e;
00244 void shape_index(const string &shape);
00245 };
00246
00247
00248
00249
00250
00251
00255 ostream& operator<<(ostream& s, const Side &sd);
00256
00257 }
00258
00259 #endif