MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
AccessorUnstructured< SolverType > Class Template Reference

#include <fvstg.h>

Inheritance diagram for AccessorUnstructured< SolverType >:
[legend]
Collaboration diagram for AccessorUnstructured< SolverType >:
[legend]

Public Member Functions

 AccessorUnstructured (MInt *sortedBndryCellIds, MInt size, SolverType *solver, const MPI_Comm &commStg, MBool cutOff)
 
MInt getNghbrMapping (MInt stgId, MInt nghbr) const
 
MInt getGhostIdFromStgId (MInt stgId) const
 
nDim_citerator iterateSlopes ()
 Solver specific implementation of the interface defined in base class. More...
 
nDim_citerator iterateSlopes_nDim_citerator_end ()
 
nDim_citerator iterateB1 ()
 
nDim_citerator iterateB1_nDim_citerator_end ()
 
nDim_citerator iterateAll ()
 
nDim_citerator iterateAll_nDim_citerator_end ()
 
MInt getCellId (const nDim_citerator &it_) const
 Helper functions for the nDim_citerator as declared in base class. More...
 
MInt getStgId (const nDim_citerator &it_) const
 
MInt getNghbr (const nDim_citerator &it_, MInt dir) const
 
MFloat a_coordinate (MInt cellId, MInt dim) const override
 
MInt domainId () const
 
MInt domainId (MInt, MInt) const override
 
MFloata_pvariable (MInt cellId, MInt varId) override
 
MFloatUInfinity () const override
 
MFloatPInfinity () const override
 
MFloatrhoInfinity () const override
 
- Public Member Functions inherited from Accessor< AccessorUnstructured< SolverType >, SolverType >
AccessorUnstructured< SolverType > * d ()
 
virtual MFloat a_coordinate (MInt, MInt) const=0
 
virtual MInt domainId (MInt, MInt) const=0
 
virtual MFloata_pvariable (MInt, MInt)=0
 
virtual MFloatUInfinity () const=0
 
virtual MFloatPInfinity () const=0
 
virtual MFloatrhoInfinity () const=0
 
MInt sizeBC () const
 
MInt sizeStg () const
 
nDim_citerator iterateSlopes ()
 
nDim_citerator iterateSlopes_nDim_citerator_end ()
 
nDim_citerator iterateB1 ()
 
nDim_citerator iterateB1_nDim_citerator_end ()
 
nDim_citerator iterateAll ()
 
nDim_citerator iterateAll_nDim_citerator_end ()
 
MInt getCellId (const nDim_citerator &it_) const
 
MInt getStgId (const nDim_citerator &it_) const
 
MInt getNghbr (const nDim_citerator &it_, MInt dir) const
 
MInt getNghbrStg (const nDim_citerator &it_, MInt dir) const
 

Public Attributes

std::vector< MIntm_stgBndry2stgGhost
 
std::vector< MIntm_stgGhost2stgBndry
 
- Public Attributes inherited from Accessor< AccessorUnstructured< SolverType >, SolverType >
SolverType *const m_solver
 
MPI_Comm m_commStg
 
Storage m_stgToCellId
 
Storage m_bcStgId
 
Storage m_stgId
 
MInt m_noBcCells
 
MInt m_stgSize
 

Private Attributes

MInt ** m_nghbrMapping = nullptr
 

Additional Inherited Members

- Public Types inherited from Accessor< AccessorUnstructured< SolverType >, SolverType >
using nDim_citerator = nDim_iterator_t< std::vector< MInt >::const_iterator, SolverType >
 
- Static Public Attributes inherited from Accessor< AccessorUnstructured< SolverType >, SolverType >
static constexpr const MInt m_nDim
 
- Protected Types inherited from Accessor< AccessorUnstructured< SolverType >, SolverType >
using Storage = std::vector< MInt >
 
using iterator = std::vector< MInt >::iterator
 
using const_iterator = std::vector< MInt >::const_iterator
 

Detailed Description

template<class SolverType>
class AccessorUnstructured< SolverType >

Definition at line 171 of file fvstg.h.

Constructor & Destructor Documentation

◆ AccessorUnstructured()

template<class SolverType >
AccessorUnstructured< SolverType >::AccessorUnstructured ( MInt sortedBndryCellIds,
MInt  size,
SolverType solver,
const MPI_Comm &  commStg,
MBool  cutOff 
)
inlineexplicit

Definition at line 182 of file fvstg.h.

185 MInt myrank = 0;
186 MPI_Comm_rank(commStg, &myrank);
187
188 // First put the boundary cells into m_stgToCellId and then append the ghost cells and finally
189 // the reconstruction neighbors, which haven't been appended already
190 m_stgToCellId.assign(sortedBndryCellIds, sortedBndryCellIds + size);
191 m_noBcCells = size;
192 assert(m_stgToCellId.size() == static_cast<MUint>(m_noBcCells));
194
195 if(!cutOff) {
196 // append ghost cells and create map from stgGhost to stgBndry
198 m_stgGhost2stgBndry.assign(2 * m_noBcCells, -1);
199 m_stgToCellId.resize(2 * m_noBcCells);
200 for(MInt id = 0; id < m_noBcCells; ++id) {
201 const MInt cellId = m_stgToCellId[id];
202 const MInt bndryId = solver->a_bndryId(cellId);
203
204 if(bndryId < 0) {
205 TERMM(1, "errror");
206 }
207
208 const MInt ghostCellId = m_solver->m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
209 m_stgToCellId[m_noBcCells + id] = ghostCellId;
212 }
213 }
214
215 m_stgSize = m_stgToCellId.size();
216
217 mAlloc(m_nghbrMapping, m_noBcCells, m_solver->m_cells.noRecNghbrs(), "m_nghbrMapping_", AT_);
218
219 if(!cutOff) {
220 // Check if cellId has been already assigned a stgId
221 using MyMap = std::map<MInt, MInt>;
222 MyMap cellIdToStgId_map;
223 auto cellIdToStgId = [this, &cellIdToStgId_map](MInt cellId) -> MInt {
224 std::pair<MyMap::const_iterator, MBool> res = cellIdToStgId_map.insert(MyMap::value_type(cellId, m_stgSize));
225 if(res.second) ++m_stgSize;
226 return res.first->second;
227 };
228 for(MInt i = 0; i < m_stgSize; ++i) {
229 cellIdToStgId_map.insert(MyMap::value_type(m_stgToCellId[i], i));
230 }
231
232 for(MInt i = 0; i < m_noBcCells; ++i) {
233 for(MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(m_stgToCellId[i]); ++nghbr) {
234 const MInt nghbrId = m_solver->a_reconstructionNeighborId(m_stgToCellId[i], nghbr);
235 const MInt stgId = cellIdToStgId(nghbrId);
236
237 m_nghbrMapping[i][nghbr] = stgId;
238
239 if(m_stgToCellId.size() <= static_cast<MUint>(stgId)) {
240 /* if(!cutOff){ */
241 if(m_solver->a_isBndryGhostCell(nghbrId)) {
242 std::cout << "NOO My rank " << myrank << "; " << nghbrId << "; " << stgId << "; "
243 << solver->a_coordinate(nghbrId, 0) << "|" << solver->a_coordinate(nghbrId, 1) << "|"
244 << solver->a_coordinate(nghbrId, 2) << std::endl;
245 TERMM(1, "ERROR");
246 }
247 /* } */
248 m_stgToCellId.push_back(nghbrId);
249 }
250 }
251 }
252
253 if(m_stgToCellId.size() != static_cast<MUint>(m_stgSize)) {
254 TERMM(1, "ERROR");
255 }
256
257 /* if(!cutOff) */ m_stgGhost2stgBndry.resize(m_stgSize, -1);
258 }
259
260 // Create list of stg Ids of only the boundary cells, which are stored at the beginning for unstructured case
261 m_bcStgId.resize(m_noBcCells);
262 std::iota(std::begin(m_bcStgId), std::end(m_bcStgId), 0); // Fill with 0, 1, ..., m_noBcCells-1
263
264 // Create list of stg Ids of all cells
265 m_stgId.resize(m_stgSize);
266 std::iota(std::begin(m_stgId), std::end(m_stgId), 0); // Fill with 0, 1, ..., m_stgSize-1
267
268
269 // Print summary
270 /* #ifndef NDEBUG */
271 /* std::cout << "--- STG INFO ---" << std::endl */
272 /* << myrank << "# bcCells/stgCells: " << m_noBcCells << " / " << m_stgSize << std::endl; */
273 /* #endif */
274 } // Constructor ends
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
Definition: alloc.h:173
Definition: fvstg.h:88
virtual MFloat a_coordinate(MInt, MInt) const =0
std::vector< MInt > m_stgBndry2stgGhost
Definition: fvstg.h:322
MInt ** m_nghbrMapping
Definition: fvstg.h:318
std::vector< MInt > m_stgGhost2stgBndry
Definition: fvstg.h:323
SolverType
Definition: enums.h:22
int32_t MInt
Definition: maiatypes.h:62
uint32_t MUint
Definition: maiatypes.h:63
MInt id
Definition: maiatypes.h:71
void const MInt cellId
Definition: collector.h:239

Member Function Documentation

◆ a_coordinate()

template<class SolverType >
MFloat AccessorUnstructured< SolverType >::a_coordinate ( MInt  cellId,
MInt  dim 
) const
inlineoverridevirtual

Implements Accessor< AccessorUnstructured< SolverType >, SolverType >.

Definition at line 309 of file fvstg.h.

309{ return m_solver->a_coordinate(cellId, dim); }

◆ a_pvariable()

template<class SolverType >
MFloat & AccessorUnstructured< SolverType >::a_pvariable ( MInt  cellId,
MInt  varId 
)
inlineoverridevirtual

Implements Accessor< AccessorUnstructured< SolverType >, SolverType >.

Definition at line 312 of file fvstg.h.

312{ return m_solver->a_pvariable(cellId, varId); }

◆ domainId() [1/2]

template<class SolverType >
MInt AccessorUnstructured< SolverType >::domainId ( ) const
inline

Definition at line 310 of file fvstg.h.

310{ return m_solver->domainId(); }

◆ domainId() [2/2]

template<class SolverType >
MInt AccessorUnstructured< SolverType >::domainId ( MInt  ,
MInt   
) const
inlineoverridevirtual

Implements Accessor< AccessorUnstructured< SolverType >, SolverType >.

Definition at line 311 of file fvstg.h.

311{ TERMM(-1, "Invalid call!"); }

◆ getCellId()

template<class SolverType >
MInt AccessorUnstructured< SolverType >::getCellId ( const nDim_citerator it_) const
inline

Definition at line 297 of file fvstg.h.

297{ return m_stgToCellId[*it_]; }

◆ getGhostIdFromStgId()

template<class SolverType >
MInt AccessorUnstructured< SolverType >::getGhostIdFromStgId ( MInt  stgId) const
inline

Definition at line 279 of file fvstg.h.

279 {
280 const MInt cellId = m_stgToCellId[stgId];
281 const MInt bndryId = m_solver->a_bndryId(cellId);
282 // TODO labels:FV,totest check if it is a boundary cell
283 return m_solver->m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
284 }

◆ getNghbr()

template<class SolverType >
MInt AccessorUnstructured< SolverType >::getNghbr ( const nDim_citerator it_,
MInt  dir 
) const
inline

Definition at line 299 of file fvstg.h.

299 {
300 const MInt cellId = m_stgToCellId[*it_];
301 if(m_solver->a_hasNeighbor(cellId, dir) > 0) {
302 return m_solver->c_neighborId(cellId, dir);
303 } else {
304 return -1;
305 }
306 }

◆ getNghbrMapping()

template<class SolverType >
MInt AccessorUnstructured< SolverType >::getNghbrMapping ( MInt  stgId,
MInt  nghbr 
) const
inline

Definition at line 277 of file fvstg.h.

277{ return m_nghbrMapping[stgId][nghbr]; }

◆ getStgId()

template<class SolverType >
MInt AccessorUnstructured< SolverType >::getStgId ( const nDim_citerator it_) const
inline

Definition at line 298 of file fvstg.h.

298{ return *it_; }

◆ iterateAll()

template<class SolverType >
nDim_citerator AccessorUnstructured< SolverType >::iterateAll ( )
inline

Definition at line 293 of file fvstg.h.

293{ return {m_stgId.begin(), this}; }

◆ iterateAll_nDim_citerator_end()

template<class SolverType >
nDim_citerator AccessorUnstructured< SolverType >::iterateAll_nDim_citerator_end ( )
inline

Definition at line 294 of file fvstg.h.

294{ return {m_stgId.end(), this}; }

◆ iterateB1()

template<class SolverType >
nDim_citerator AccessorUnstructured< SolverType >::iterateB1 ( )
inline

Definition at line 290 of file fvstg.h.

290{ return {m_bcStgId.begin(), this}; }

◆ iterateB1_nDim_citerator_end()

template<class SolverType >
nDim_citerator AccessorUnstructured< SolverType >::iterateB1_nDim_citerator_end ( )
inline

Definition at line 291 of file fvstg.h.

291{ return {m_bcStgId.end(), this}; }

◆ iterateSlopes()

template<class SolverType >
nDim_citerator AccessorUnstructured< SolverType >::iterateSlopes ( )
inline

Definition at line 287 of file fvstg.h.

287{ return {m_bcStgId.begin(), this}; }

◆ iterateSlopes_nDim_citerator_end()

template<class SolverType >
nDim_citerator AccessorUnstructured< SolverType >::iterateSlopes_nDim_citerator_end ( )
inline

Definition at line 288 of file fvstg.h.

288{ return {m_bcStgId.end(), this}; }

◆ PInfinity()

template<class SolverType >
MFloat & AccessorUnstructured< SolverType >::PInfinity ( ) const
inlineoverridevirtual

Implements Accessor< AccessorUnstructured< SolverType >, SolverType >.

Definition at line 314 of file fvstg.h.

314{ return m_solver->m_PInfinity; }

◆ rhoInfinity()

template<class SolverType >
MFloat & AccessorUnstructured< SolverType >::rhoInfinity ( ) const
inlineoverridevirtual

Implements Accessor< AccessorUnstructured< SolverType >, SolverType >.

Definition at line 315 of file fvstg.h.

315{ return m_solver->m_rhoInfinity; }

◆ UInfinity()

template<class SolverType >
MFloat & AccessorUnstructured< SolverType >::UInfinity ( ) const
inlineoverridevirtual

Implements Accessor< AccessorUnstructured< SolverType >, SolverType >.

Definition at line 313 of file fvstg.h.

313{ return m_solver->m_UInfinity; }

Member Data Documentation

◆ m_nghbrMapping

template<class SolverType >
MInt** AccessorUnstructured< SolverType >::m_nghbrMapping = nullptr
private

Definition at line 318 of file fvstg.h.

◆ m_stgBndry2stgGhost

template<class SolverType >
std::vector<MInt> AccessorUnstructured< SolverType >::m_stgBndry2stgGhost

Definition at line 322 of file fvstg.h.

◆ m_stgGhost2stgBndry

template<class SolverType >
std::vector<MInt> AccessorUnstructured< SolverType >::m_stgGhost2stgBndry

Definition at line 323 of file fvstg.h.


The documentation for this class was generated from the following file: