bvp::domain Class Reference

#include <bvp.hpp>

Inheritance diagram for bvp::domain:

Inheritance graph
[legend]
Collaboration diagram for bvp::domain:

Collaboration graph
[legend]

List of all members.

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, vectornormals


Detailed Description

A domain is a bunch of interior points, a bunch of boundary points, and a normal vector at each boundary point.

Constructor & Destructor Documentation

bvp::domain::domain ( size_t  dimension  ) 

Allocate empty domain of given dimension.

00019                                 {
00020     dim = dimension;
00021   }

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   }

Here is the call graph for this function:

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.

Parameters:
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   }

Here is the call graph for this function:

bvp::domain::~domain (  )  [virtual]

00100                  {
00101     //Nothing!
00102   }

bvp::domain::domain (  )  [private]

Can't create a domain without at least specifying its dimension.


Member Function Documentation

void bvp::domain::set_dimension ( size_t  dimension  ) 

This clears any data already in the domain and sets the dimension.

00105                                             {
00106     dim = dimension;
00107     interior.clear();
00108     boundary.clear();
00109     normals.clear();
00110   }

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.

Parameters:
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   }

Here is the call graph for this function:

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.

Parameters:
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   }

Here is the call graph for this function:

size_t bvp::domain::get_dimension (  )  const

Get the domain's dimension.

00206                                     {
00207     return dim;
00208   }

const set< point > & bvp::domain::get_interior (  )  const

Get the interior.

00209                                               {
00210     return interior;
00211   }

const set< point > & bvp::domain::get_boundary (  )  const

Get the boundary.

00212                                               {
00213     return boundary;
00214   }

const map< point, vector > & bvp::domain::get_normals (  )  const

Get the normals.

00215                                                      {
00216     return normals;
00217   }

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   }

Here is the call graph for this function:


Member Data Documentation

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]


The documentation for this class was generated from the following files:

Generated on Fri Jun 6 17:28:25 2008 by  doxygen 1.5.6