| 1 |
///////////////////////////////////////////////////////////// |
| 2 |
// // |
| 3 |
// Copyright (c) 2007-2017 by The University of Queensland // |
| 4 |
// Centre for Geoscience Computing // |
| 5 |
// http://earth.uq.edu.au/centre-geoscience-computing // |
| 6 |
// // |
| 7 |
// Primary Business: Brisbane, Queensland, Australia // |
| 8 |
// Licensed under the Open Software License version 3.0 // |
| 9 |
// http://www.apache.org/licenses/LICENSE-2.0 // |
| 10 |
// // |
| 11 |
///////////////////////////////////////////////////////////// |
| 12 |
|
| 13 |
#include "Model2D.h" |
| 14 |
|
| 15 |
// --- IO includes --- |
| 16 |
#include <fstream> |
| 17 |
#include <iostream> |
| 18 |
|
| 19 |
using std::ofstream; |
| 20 |
using std::endl; |
| 21 |
|
| 22 |
/*! |
| 23 |
constructor |
| 24 |
|
| 25 |
\param Pmin minimum point |
| 26 |
\param Pmax maximum point |
| 27 |
\param cdim cell dimension for neigbour table |
| 28 |
*/ |
| 29 |
Model2D::Model2D(const Vector3& Pmin,const Vector3& Pmax,double cdim) |
| 30 |
{ |
| 31 |
m_ntable=new MNTable2D(Pmin,Pmax,cdim,1); |
| 32 |
m_ngroups=1; |
| 33 |
m_max_gid=-1; |
| 34 |
m_min_pt=Pmin; |
| 35 |
m_max_pt=Pmax; |
| 36 |
} |
| 37 |
|
| 38 |
/*! |
| 39 |
destructor |
| 40 |
*/ |
| 41 |
Model2D::~Model2D() |
| 42 |
{ |
| 43 |
if(m_ntable!=NULL) delete m_ntable; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
/*! |
| 48 |
Add particle group |
| 49 |
|
| 50 |
\param PGPtr pointer to particle group |
| 51 |
\return id of the particle group |
| 52 |
*/ |
| 53 |
int Model2D::AddParticleGroup(AParticleGroup* PGPtr) |
| 54 |
{ |
| 55 |
m_max_gid++; |
| 56 |
if(m_max_gid>=m_ngroups){ |
| 57 |
m_ngroups=m_ngroups*2; |
| 58 |
m_ntable->GrowNGroups(m_ngroups); |
| 59 |
} |
| 60 |
PGPtr->Init(m_ntable,m_max_gid); |
| 61 |
m_pgroups.push_back(PGPtr); |
| 62 |
|
| 63 |
return m_max_gid; |
| 64 |
} |
| 65 |
|
| 66 |
/*! |
| 67 |
Write Geonmetry out to file |
| 68 |
|
| 69 |
\param filename the filename |
| 70 |
*/ |
| 71 |
void Model2D::WriteAsGeoFile(const string& filename) |
| 72 |
{ |
| 73 |
ofstream outfile(filename.c_str()); |
| 74 |
|
| 75 |
outfile << "LSMGeometry 1.2" << endl; |
| 76 |
outfile << "BoundingBox" << m_min_pt << " " << m_max_pt << endl; |
| 77 |
outfile << "PeriodicBoundaries 0 0 0" << endl; |
| 78 |
outfile << "Dimension 2D" << endl; |
| 79 |
outfile << *m_ntable; |
| 80 |
|
| 81 |
outfile.close(); |
| 82 |
} |