Multidimensional Programming with GSSE

Modern application design is based on the mechanisms of abstraction. In this tutorial we demonstrate multidimensional programming with the GSSE. This means that the actual algorithm need not include the dimension or number of objects. Instead iterators can be used to abstract the given number of objects away and use a concise interface through all dimensions and types of input files.

The generic topology library of the GSSE addresses this issues with a homogeneous interface for all different dimensions and types of topological spaces as well as a comprehensive and complete iterator hierarchy which is generated at compile time.

Tasks

C++ Reference Implementation with GSSE

// .. include the dimension you need for this tutorial
// 
#include "gsse/gsse_2d_unstructured.hpp"

// .. open the gsse namespace for your convenience
//
using namespace gsse;

long test(std::string infilename)
{

	// use some strings for your variables
	//
   	std::string key_vertex         = "vertex_volume";      

	// prepare the structure
	//
   	domain_t domain;
   	segment_iterator segit;                                       
   	domain.read_file(infilename);
   	segit = domain.segment_begin();

	// iterate over all cells 
	//
  	for (cell_iterator cit = (*segit).cell_begin(); cit != (*segit).cell_end(); ++cit)
    	{     
		// sub-dimensional iteration.. all vertices on a given cell
		//
       		domain_traits<domain_t>::vertex_on_cell_iterator iter1(*cit);  
       		double mean_value = 0;
		long count_iterator = 0;
                // the gsse data pattern type.. a simple matrix.. 
                //
                data_pattern_type entry(1, 1, 0.0);

	       	while(iter1.valid())
       		{	 
			(*segit).retrieve_quantity(*iter1, key_vertex, entry);
			mean_value += entry(0,0); 
          
	  		++iter1;
			++count_iterator;
       		}     
		mean_value /= count_iterator;
		std::cout << "mean value of the entries: " << mean_value << std::endl;
		mean_value = 0.0;
		count_iterator=0;
	}	 
  	

  	return 0;
}



int main(int argc, char** argv)
{
	// use the filename
	// 

 	if (argc < 2)
	{
		std::cout << "./progname inputfile.gau2" << std::endl;
		exit (-1);
	}
	test(argv[1]);
  	return 0;
}