![]() |
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 00004 #ifndef __BOUNDARY_CONDITION_H 00005 #define __BOUNDARY_CONDITION_H 00006 00007 #include <dolfin/dolfin_log.h> 00008 #include <dolfin/Node.h> 00009 #include <dolfin/Point.h> 00010 #include <dolfin/constants.h> 00011 00012 namespace dolfin { 00013 00014 class BoundaryCondition { 00015 public: 00016 00017 enum Type { DIRICHLET, NEUMANN }; 00018 00019 BoundaryCondition(int components = 1) { 00020 this->components = components; 00021 _type = NEUMANN; 00022 np = 0; 00023 _val = new real[components]; 00024 00025 for(int i = 0; i < components; i++) 00026 { 00027 _val[i] = 0.0; 00028 } 00029 } 00030 00031 ~BoundaryCondition() { 00032 delete [] _val; 00033 } 00034 00035 Point coord() const { 00036 if ( np == 0 ) 00037 dolfin_error("Node is not specified."); 00038 return np->coord(); 00039 } 00040 00041 const Node& node() const { 00042 if ( np == 0 ) 00043 dolfin_error("Node is not specified."); 00044 return *np; 00045 } 00046 00047 Type type() const { 00048 return _type; 00049 } 00050 00051 real val(int component = 0) const { 00052 return _val[component]; 00053 } 00054 00055 void set(Type type, real val, int component = 0) { 00056 _type = type; 00057 _val[component] = val; 00058 } 00059 00060 friend class FEM; 00061 00062 //private: 00063 00064 void update(Node* np) { 00065 this->np = np; 00066 _type = NEUMANN; 00067 00068 for(int i = 0; i < components; i++) 00069 { 00070 _val[i] = 0.0; 00071 } 00072 } 00073 00074 private: 00075 00076 Node* np; 00077 00078 Type _type; 00079 real* _val; 00080 int components; 00081 }; 00082 00083 } 00084 00085 #endif
![]()
Documentation automatically generated with Doxygen on 10 Sep 2004.