Hi,
There is something I do not understand. I wanted to use OneCellIndexedFunctional to compute an average of my lattice over time but without success. I tried something simple like copying a lattice, but no more success. Here is my code of copy:
[code=“cpp”]
template<typename T, template class Descriptor>
class CopyLatticeCell : public OneCellIndexedFunctional3D<T,Descriptor>
{
public:
CopyLatticeCell(MultiBlockLattice3D<T,Descriptor>* s) : source(s) {}
CopyLatticeCell<T,Descriptor>* clone() const {
return new CopyLatticeCell<T,Descriptor>(*this); }
virtual void execute(plint iX, plint iY, plint iZ, Cell<T,Descriptor>& cell) const
{
Cell<T,Descriptor>& cell_source = source->get(iX,iY,iZ);
for (plint i = 0; i < n; i++) { cell[i] = cell_source[i]; }
}
private:
MultiBlockLattice3D<T,Descriptor>* source;
const static plint n = CellInfo<T,Descriptor>::n;
};
void copy(MultiBlockLattice3D<T,DESCRIPTOR>& sourceLattice,
MultiBlockLattice3D<T,DESCRIPTOR>& resultLattice)
{
applyIndexed(resultLattice, resultLattice.getBoundingBox(),
new CopyLatticeCell<T,DESCRIPTOR>(&sourceLattice));
}
To use it just add at the end of a computation
[code="cpp"]
copy(lattice, result_lattice);
I declare result_lattice in the same time I declare lattice. The result lattice has the BC fine (from creation) but velocity is zero elsewhere. If you have any idea…
TIA,
Olivier.