Skip to content
Snippets Groups Projects
Commit 03b27191 authored by Oliver Sander's avatar Oliver Sander
Browse files

New constructor with control over the UG environment heap size

[[Imported from SVN: r962]]
parent 56de3a85
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@
namespace Dune
{
/** @defgroup UGGrid UGGridImp
/** @defgroup UGGrid UGGrid
\ingroup GridCommon
This is the implementation of the grid interface
......@@ -157,11 +157,19 @@ namespace Dune {
/** \brief Constructor with control over UG's memory requirements
*
* \param heap The size of UG's internal memory in megabytes. UG allocates
* \param heapSize The size of UG's internal memory in megabytes. UG allocates
* memory only once. I don't know what happens if you create UGGrids with
* differing heap sizes.
* \param envHeapSize The size of UG's environment heap.
*/
UGGrid(unsigned int heap=500);
UGGrid(unsigned int heapSize, unsigned int envHeapSize);
/** \brief Constructor with default memory settings
*
* The default values are 500MB for the general heap and 10MB for
* the environment heap.
*/
UGGrid();
//! Desctructor
~UGGrid();
......@@ -215,6 +223,9 @@ namespace Dune {
void* extra_boundary_data_;
private:
void init(unsigned int heapSize, unsigned int envHeapSize);
// Each UGGrid object has a unique name to identify it in the
// UG environment structure
std::string name_;
......@@ -228,6 +239,11 @@ namespace Dune {
// number of entitys of each level an codim
Array<int> size_;
//! Marks whether the UG environment heap size is taken from
//! an existing defaults file or whether the values from
//! the UGGrid constructor are taken
bool useExistingDefaultsFile;
protected:
/** \brief Number of UGGrids currently in use.
*
......
......@@ -30,10 +30,41 @@ namespace Dune
template<> int UGGrid < 3, 3 >::numOfUGGrids = 0;
template < int dim, int dimworld >
inline UGGrid < dim, dimworld >::UGGrid(unsigned int heap) : heapsize(heap)
inline UGGrid < dim, dimworld >::UGGrid()
{
init(500, 10);
}
template < int dim, int dimworld >
inline UGGrid < dim, dimworld >::UGGrid(unsigned int heapSize, unsigned envHeapSize)
{
init(heapSize, envHeapSize);
}
template < int dim, int dimworld >
inline void UGGrid < dim, dimworld >::init(unsigned int heapSize, unsigned envHeapSize)
{
heapsize = heapSize;
if (numOfUGGrids==0) {
useExistingDefaultsFile = false;
if (access("defaults", F_OK) == 0) {
std::cout << "Using existing UG defaults file" << std::endl;
useExistingDefaultsFile = true;
} else {
// Pass the explicitly given environment heap size
// This is only possible by passing a pseudo 'defaults'-file
FILE* fp = fopen("defaults", "w");
fprintf(fp, "envmemory %d000000\n", envHeapSize);
fclose(fp);
}
// Init the UG system
int argc = 1;
char* arg = {"dune.exe"};
......@@ -58,7 +89,6 @@ namespace Dune
1,coeffs,1,upp) == NULL)
assert(false);
// A Dummy new format
// We need to pass the parameters in this complicated way, because
// UG writes into one of the strings, and code compiled by some
......@@ -116,6 +146,10 @@ namespace Dune
for (int i=0; i<4; i++)
free(newformatArgs[i]);
// remove defaults file, if we wrote one on startup
if (!useExistingDefaultsFile)
system("rm defaults");
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment