noh_amr.cpp
1 #include "noh_amr.hpp"
2 
3 NohRefine::NohRefine(double Vmax):Vmax_(Vmax)
4 {}
5 
7 {}
8 
9 vector<int> NohRefine::CellsToRefine
10 (Tessellation const& tess,
11  vector<ComputationalCell> const& /*cells*/,
12  double /*time*/,
13  vector<Vector2D> &directions,
14  vector<int> const& Removed)
15 {
16  vector<int> res;
17  directions.clear();
18  int n=tess.GetPointNo();
19  for(int i=0;i<n;++i)
20  {
21  // Are we too big? If so add to the refinement list
22  if(tess.GetVolume(i)>Vmax_)
23  {
24  res.push_back(i);
25  // Give a prefered splitting direction, this is not really needed in this case since the default scheme works very well
26  Vector2D point=tess.GetMeshPoint(i);
27  directions.push_back(Vector2D(point.x,point.y)/abs(point));
28  }
29  }
30  // Make sure we are not splitting a cell turn after turn
31  return RemoveDuplicatedLately(res,tess.GetPointNo(),directions,
32  Removed,tess);
33 }
34 
35 NohRemove::NohRemove(double Vmin):Vmin_(Vmin)
36 {}
37 
39 {}
40 
41 vector<int> NohRemove::CellsToRemove
42 (Tessellation const& tess,
43  vector<ComputationalCell> const& /*cells*/,
44  double /*time*/)const
45 {
46  vector<int> ToRemoveTemp;
47  vector<double> merit;
48  int n=tess.GetPointNo();
49  for(int i=0;i<n;++i)
50  {
51  if(tess.GetVolume(i)<Vmin_)
52  {
53  ToRemoveTemp.push_back(i);
54  merit.push_back(tess.GetVolume(i));
55  }
56  }
57  // Make sure there are no neighbors
58  vector<int> ToRemove=RemoveNeighbors(merit,ToRemoveTemp,tess);
59  // Be 100% sure we removed the neighbors correctly
60  CheckOutput(tess,ToRemove);
61  return ToRemove;
62 }
NohRefine(double Vmax)
Class constructor.
Definition: noh_amr.cpp:3
Abstract class for tessellation.
virtual int GetPointNo(void) const =0
Get Total number of mesh generating points.
void CheckOutput(Tessellation const &tess, vector< int > &ToRemove) const
Checks if the removed list is good, throws an error if not.
vector< int > RemoveDuplicatedLately(vector< int > const &ToRefine, int Npoints, vector< Vector2D > &directions, vector< int > const &Removed, Tessellation const &tess)
Removes cells that were splitted in the last time step.
~NohRemove()
Class destructor.
Definition: noh_amr.cpp:38
virtual Vector2D GetMeshPoint(int index) const =0
Returns Position of mesh generating point.
double y
Component in the y direction.
Definition: geometry.hpp:48
~NohRefine()
Class destructor.
Definition: noh_amr.cpp:6
virtual double GetVolume(int index) const =0
Returns the volume of a cell.
vector< int > CellsToRefine(Tessellation const &tess, vector< ComputationalCell > const &cells, double time, vector< Vector2D > &directions, vector< int > const &Removed)
Calculates the cells to be refined.
Definition: noh_amr.cpp:10
vector< int > CellsToRemove(Tessellation const &tess, vector< ComputationalCell > const &cells, double time) const
Removal abstract class. Can&#39;t remove neighboring cells or cells near peiodic boundary. Use CheckOutput to check correctness.
Definition: noh_amr.cpp:42
AMR scheme for the noh problem.
double abs(Vector3D const &v)
Norm of a vector.
Definition: Vector3D.cpp:44
vector< int > RemoveNeighbors(vector< double > const &merits, vector< int > const &candidates, Tessellation const &tess) const
Removes neighboring points and cells near the boundary which are not rigid walls. ...
2D Mathematical vector
Definition: geometry.hpp:15
NohRemove(double Vmin)
Class constructor.
Definition: noh_amr.cpp:35
double x
Component in the x direction.
Definition: geometry.hpp:45