File: Model2D.cc

package info (click to toggle)
python-demgengeo 1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,004 kB
  • ctags: 2,158
  • sloc: cpp: 12,532; python: 1,260; makefile: 281; sh: 92
file content (82 lines) | stat: -rw-r--r-- 1,964 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2007-2014 by The University of Queensland //
// Centre for Geoscience Computing                         //
// http://earth.uq.edu.au/centre-geoscience-computing      //
//                                                         //
// Primary Business: Brisbane, Queensland, Australia       //
// Licensed under the Open Software License version 3.0    //
// http://www.opensource.org/licenses/osl-3.0.php          //
//                                                         //
/////////////////////////////////////////////////////////////

#include "Model2D.h"

// --- IO includes ---
#include <fstream>
#include <iostream>

using std::ofstream;
using std::endl;

/*!
  constructor

  \param Pmin minimum point
  \param Pmax maximum point
  \param cdim cell dimension for neigbour table
*/
Model2D::Model2D(const Vector3& Pmin,const Vector3& Pmax,double cdim)
{
  m_ntable=new MNTable2D(Pmin,Pmax,cdim,1);
  m_ngroups=1;
  m_max_gid=-1;
  m_min_pt=Pmin;
  m_max_pt=Pmax;
}

/*!
  destructor
*/
Model2D::~Model2D()
{
  if(m_ntable!=NULL) delete m_ntable;
}


/*!
  Add particle group

  \param PGPtr pointer to particle group
  \return id of the particle group
*/
int Model2D::AddParticleGroup(AParticleGroup* PGPtr)
{
  m_max_gid++;
  if(m_max_gid>=m_ngroups){
    m_ngroups=m_ngroups*2;
    m_ntable->GrowNGroups(m_ngroups);
  }
  PGPtr->Init(m_ntable,m_max_gid);
  m_pgroups.push_back(PGPtr);

  return m_max_gid;
}

/*!
  Write Geonmetry out to file

  \param filename the filename
*/
void Model2D::WriteAsGeoFile(const string& filename)
{
  ofstream outfile(filename.c_str());

  outfile << "LSMGeometry 1.2" << endl;
  outfile << "BoundingBox" << m_min_pt << " " << m_max_pt << endl;
  outfile << "PeriodicBoundaries 0 0 0" << endl;
  outfile << "Dimension 2D" << endl;
  outfile << *m_ntable;

  outfile.close();
}