#include <bvp.hpp>
Public Member Functions | |
domain (size_t dimension) | |
Allocate empty domain of given dimension. | |
domain (size_t dimension, set< point > intr, set< point > bdry, map< point, vector > ns) | |
Allocate domain given a boundary, an interior, and a set of normals. | |
domain (string intr, string bdry, string ns) | |
void | set_dimension (size_t dimension) |
This clears any data already in the domain and sets the dimension. | |
void | add_to_interior (const set< point > &intr) |
Add a set of points to the interior of the domain. | |
void | add_to_interior (const point &intr) |
Add a point to the interior of the domain. | |
void | add_to_boundary (const set< point > &bdry) |
Add a set of points to the boundary of the domain. | |
void | add_to_boundary (const point &bdry) |
Add a point to the boundary of the domain. | |
void | add_to_normals (const map< point, vector > &ns) |
Add a set of normals to the domain. | |
void | add_to_normals (const point &bdry, const vector &n) |
Add a normal to the domain Every normal added to the domain must be attached to a boundary point already in the domain. | |
size_t | get_dimension () const |
Get the domain's dimension. | |
const set< point > & | get_interior () const |
Get the interior. | |
const set< point > & | get_boundary () const |
Get the boundary. | |
const map< point, vector > & | get_normals () const |
Get the normals. | |
bool | contains (const point &p) const |
Is point in this domain, whether interior or boundary? | |
virtual | ~domain () |
Private Member Functions | |
domain () | |
Private Attributes | |
size_t | dim |
set< point > | interior |
set< point > | boundary |
map< point, vector > | normals |
bvp::domain::domain | ( | size_t | dimension | ) |
bvp::domain::domain | ( | size_t | dimension, | |
set< point > | intr, | |||
set< point > | bdry, | |||
map< point, vector > | ns | |||
) |
Allocate domain given a boundary, an interior, and a set of normals.
00023 { 00024 dim = dimension; 00025 add_to_interior(intr); 00026 add_to_boundary(bdry); 00027 add_to_normals(ns); 00028 }
bvp::domain::domain | ( | string | intr, | |
string | bdry, | |||
string | ns | |||
) |
/brief Construct the domain from filenames.
Each file containing the desired points as a matrix structure where the number of columns must be the dimensionality of the points and each row is one point.
The normals are given by a matrix with number of columns twice that of the interior and boundary, with the first part of the columns giving the basepoint and the second part of the columns giving the normal itself.
A boundary or interior matrix can be empty, but the normals matrix can't be empty if the boundary isn't.
intr | - Filename holding the interior of the domain. | |
bdry | - Filename holding the boundary of the domain. | |
ns | - Filename holding the normals of the domain. |
00030 { 00031 using namespace utils; 00032 using namespace linalg; 00033 using namespace error_handling; 00034 00035 bool intr_empty, bdry_empty; 00036 00037 matrix intr_m ; 00038 try{ 00039 intr_m = read_matrix(intr); 00040 intr_empty = false; 00041 } 00042 catch(endOfFile){ 00043 intr_empty = true; 00044 } 00045 00046 matrix bdry_m; 00047 try{ 00048 bdry_m = read_matrix(bdry); 00049 bdry_empty = false; 00050 } 00051 catch(endOfFile){ 00052 bdry_empty = true; 00053 } 00054 00055 matrix ns_m; 00056 try{ 00057 ns_m = read_matrix(ns); 00058 } 00059 catch(endOfFile& exc){ 00060 if(!bdry_empty){ 00061 exc.reason = "Boundary is not empty, so normals cannot be either."; 00062 throw exc; 00063 } 00064 } 00065 00066 dim = intr_m.cols(); 00067 if( bdry_m.cols() != dim and !bdry_empty ){ 00068 badArgument exc; 00069 exc.reason = 00070 "Wrong parameters for domain from filename. \n" 00071 "Dimension of boundary (columns) must equal dimension of interior."; 00072 exc.line = __LINE__; 00073 exc.file = __FILE__; 00074 throw exc; 00075 } 00076 if( ns_m.cols() != 2*dim and !bdry_empty){ 00077 badArgument exc; 00078 exc.reason = 00079 "Wrong parameters for domain from filename. \n" 00080 "Dimension of normals (columns) must equal twice the \n" 00081 "dimension of the interior and the boundary."; 00082 exc.line = __LINE__; 00083 exc.file = __FILE__; 00084 throw exc; 00085 } 00086 slice s(1,dim), s1(1,dim), s2(dim+1,2*dim); 00087 00088 if(!intr_empty) 00089 for(size_t i = 1; i <= intr_m.rows(); i++) 00090 add_to_interior( intr_m(i,s) ); 00091 00092 if(!bdry_empty){ 00093 for(size_t i = 1; i <= bdry_m.rows(); i++) 00094 add_to_boundary( bdry_m(i,s) ); 00095 for(size_t i = 1; i <= ns_m.rows(); i++) 00096 add_to_normals(ns_m(i,s1), ns_m(i, s2)); 00097 } 00098 }
bvp::domain::domain | ( | ) | [private] |
Can't create a domain without at least specifying its dimension.
void bvp::domain::set_dimension | ( | size_t | dimension | ) |
void bvp::domain::add_to_interior | ( | const set< point > & | intr | ) |
Add a set of points to the interior of the domain.
00113 { 00114 for(set<point>::const_iterator I = intr.begin(); I != intr.end(); I++){ 00115 if(I -> size() != dim){ 00116 badArgument exc; 00117 exc.reason = 00118 "Cannot assign to domain's interior: inconformant dimensions."; 00119 exc.line = __LINE__; 00120 exc.file = __FILE__; 00121 throw exc; 00122 } 00123 interior.insert(*I); 00124 } 00125 }
void bvp::domain::add_to_interior | ( | const point & | intr | ) |
Add a point to the interior of the domain.
00127 { 00128 if(intr.size() != dim){ 00129 badArgument exc; 00130 exc.reason = 00131 "Cannot assign to domain's interior: inconformant dimensions."; 00132 exc.line = __LINE__; 00133 exc.file = __FILE__; 00134 throw exc; 00135 } 00136 interior.insert(intr); 00137 }
void bvp::domain::add_to_boundary | ( | const set< point > & | bdry | ) |
Add a set of points to the boundary of the domain.
00139 { 00140 for(set<point>::const_iterator I = bdry.begin(); I != bdry.end(); I++){ 00141 if(I -> size() != dim){ 00142 badArgument exc; 00143 exc.reason = 00144 "Cannot assign to domain's boundary: inconformant dimensions."; 00145 exc.line = __LINE__; 00146 exc.file = __FILE__; 00147 throw exc; 00148 } 00149 boundary.insert(*I); 00150 } 00151 }
void bvp::domain::add_to_boundary | ( | const point & | bdry | ) |
Add a point to the boundary of the domain.
00153 { 00154 if(bdry.size() != dim){ 00155 badArgument exc; 00156 exc.reason = 00157 "Cannot assign to domain's boundary: inconformant dimensions."; 00158 exc.line = __LINE__; 00159 exc.file = __FILE__; 00160 throw exc; 00161 } 00162 boundary.insert(bdry); 00163 }
void bvp::domain::add_to_normals | ( | const map< point, vector > & | ns | ) |
Add a set of normals to the domain.
Every normal added to the domain must be attached to a boundary point already in the domain.
ns | - A set of normals to add. |
00165 { 00166 for(map<point, vector>::const_iterator I = ns.begin(); 00167 I != ns.end(); I++){ 00168 if (!utils::contains(boundary, I->first)){ 00169 badArgument exc; 00170 exc.reason = "Bad normal given: must match a point on the boundary."; 00171 exc.line = __LINE__; 00172 exc.file = __FILE__; 00173 throw exc; 00174 } 00175 if(I->first.size() != dim or I->second.size() != dim){ 00176 badArgument exc; 00177 exc.reason = "Bad normal given: inconformant dimensions."; 00178 exc.line = __LINE__; 00179 exc.file = __FILE__; 00180 throw exc; 00181 } 00182 normals.insert(*I); 00183 } 00184 }
void bvp::domain::add_to_normals | ( | const point & | bdry, | |
const vector & | n | |||
) |
Add a normal to the domain Every normal added to the domain must be attached to a boundary point already in the domain.
bdry | - The boundary point where to attach this normal. | |
n | - A normal to add. |
00186 { 00187 if (!utils::contains(boundary, bdry)){ 00188 badArgument exc; 00189 exc.reason = "Bad normal given: must match a point on the boundary."; 00190 exc.line = __LINE__; 00191 exc.file = __FILE__; 00192 throw exc; 00193 } 00194 if(bdry.size() != dim or n.size() != dim){ 00195 badArgument exc; 00196 exc.reason = "Bad normal given: inconformant dimensions."; 00197 exc.line = __LINE__; 00198 exc.file = __FILE__; 00199 throw exc; 00200 } 00201 pair<point, vector> pn = make_pair(bdry,n); 00202 normals.insert(pn); 00203 }
size_t bvp::domain::get_dimension | ( | ) | const |
const set< point > & bvp::domain::get_interior | ( | ) | const |
const set< point > & bvp::domain::get_boundary | ( | ) | const |
const map< point, vector > & bvp::domain::get_normals | ( | ) | const |
bool bvp::domain::contains | ( | const point & | p | ) | const |
Is point in this domain, whether interior or boundary?
00220 { 00221 if(utils::contains(interior, p)) 00222 return true; 00223 if(utils::contains(boundary, p)) 00224 return true; 00225 return false; 00226 }
size_t bvp::domain::dim [private] |
set<point> bvp::domain::interior [private] |
set<point> bvp::domain::boundary [private] |
map<point, vector> bvp::domain::normals [private] |