Memosa-FVM  0.2
FVMParticles.cpp
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #include <iostream>
6 #include "FVMParticles.h"
7 #include "CRConnectivity.h"
8 
9 using namespace std;
10 
12 :_meshList( meshList ), _sweepIter(5)
13 {
14  _nmesh = _meshList.size();
15  _cellIDSet.resize( _nmesh );
16 
17 }
18 
19 
21 {
22 
23 }
24 
25 void
27 {
28  _sweepIter = nsweep;
29  assert( _sweepIter > 0 );
30  //loop over meshes
31  for ( int id = 0; id < _nmesh; id++){
32  const Array<int>& cellType = _meshList.at(id)->getIBType();
33  const Array<int>& faceIBList = _meshList.at(id)->getIBFaceList();
34  const CRConnectivity& cellCells = _meshList.at(id)->getCellCells();
35  const CRConnectivity& faceCells = _meshList.at(id)->getAllFaceCells();
36  int num_inner_cells = _meshList.at(id)->getCells().getSelfCount();
37  vector<int> sweep_particles_old;
38  vector<int> sweep_particles_new;
39  for ( int sweep = 0; sweep < _sweepIter; sweep++ ){
40  //loop over cells on a mesh
41  if ( sweep == 0 )
42  for ( int n = 0; n < faceIBList.getLength(); n++){
43  //loop over surrounding cells of a cell only if it is immersed boundary or if it is a fvm particle
44  int face_id = faceIBList[n];
45  int cell0 = faceCells( face_id, 0);
46  int cell1 = faceCells( face_id, 1);
47  int cell_id = -1;
48  if ( cellType[cell0] == Mesh::IBTYPE_BOUNDARY )
49  cell_id = cell0;
50  else
51  cell_id = cell1;
52 
53  //cout << " immersed_cells id = " << cell_id << endl;
54  int count_neigh_cells = cellCells.getCount(cell_id);
55  for ( int j = 0; j < count_neigh_cells; j++){
56  int neigh_cell_id = cellCells(cell_id, j);
57  bool is_fvm_particle = (_cellIDSet.at(id).count(neigh_cell_id) == 0) && (cellType[neigh_cell_id] == Mesh::IBTYPE_FLUID) &&
58  (neigh_cell_id < num_inner_cells);
59  //accept only if it is a fluid and not in _cellIDSet
60  if ( is_fvm_particle ){
61  _cellIDSet.at(id).insert( neigh_cell_id );
62  sweep_particles_old.push_back( neigh_cell_id );
63  }
64  }
65  }
66 
67  if ( sweep > 0 )
68  for ( int n = 0; n < int( sweep_particles_old.size() ); n++){
69  int cell_id = sweep_particles_old.at(n);
70  int count_neigh_cells = cellCells.getCount(n);
71  for ( int j = 0; j < count_neigh_cells; j++){
72  int neigh_cell_id = cellCells(cell_id, j);
73  bool is_fvm_particle = (_cellIDSet.at(id).count(neigh_cell_id) == 0) && (cellType[neigh_cell_id] == Mesh::IBTYPE_FLUID) &&
74  (neigh_cell_id < num_inner_cells);
75  //accept only if it is a fluid and not in _cellIDSet
76  if ( is_fvm_particle ){
77  _cellIDSet.at(id).insert( neigh_cell_id );
78  sweep_particles_new.push_back( neigh_cell_id );
79  }
80  }
81  }
82 
83  //replace old with new one
84  if ( sweep > 0 ){
85  sweep_particles_old.resize( sweep_particles_new.size() );
86  sweep_particles_old = sweep_particles_new;
87  }
88  cout << "sweep_end = " << sweep << endl;
89  }
90  }
91 
92  //setting array values from data sets
93  for ( int id = 0; id < _nmesh; id++ ){
94  int array_size = _cellIDSet.at(id).size();
95  _cellID.push_back( ArrayIntPtr( new Array<int>(array_size) ) );
96  set<int>::const_iterator it;
97  int indx = 0;
98  for ( it = _cellIDSet.at(id).begin(); it != _cellIDSet.at(id).end(); it++)
99  (*_cellID.at(id))[indx++] = *it;
100  }
101 
102 
103 }
104 
int getCount(const int i) const
void setParticles(int sweep)
vector< set< int > > _cellIDSet
Definition: FVMParticles.h:33
shared_ptr< Array< int > > ArrayIntPtr
Definition: FVMParticles.h:16
vector< ArrayIntPtr > _cellID
Definition: FVMParticles.h:34
const MeshList _meshList
Definition: FVMParticles.h:29
FVMParticles(const MeshList &meshList)
vector< Mesh * > MeshList
Definition: Mesh.h:439
int getLength() const
Definition: Array.h:87