CellParticleCachingPolicy.h 2.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
//
// Class CellParticleCachingPolicy
//
//   The Cell caching layout ensures that each node has all ghost particles
//   for each external particle that is inside a neighboring cell.
//
//   Please note: for the time being this class is *not* used! But since it
//   might be used in future projects, we keep this file.
//
// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//

gsell's avatar
gsell committed
24 25 26 27 28 29 30 31 32 33 34 35
#ifndef CELL_PARTICLE_CACHING_POLICY
#define CELL_PARTICLE_CACHING_POLICY

#include <Particle/BoxParticleCachingPolicy.h>

template<class T, unsigned Dim, class Mesh>
class CellParticleCachingPolicy : private BoxParticleCachingPolicy<T,Dim,Mesh> {
public:
	CellParticleCachingPolicy()
	{
		std::fill(cells, cells+Dim, 0);
	}
36

gsell's avatar
gsell committed
37 38 39 40
	void setCacheCellRange(int d, int length)
	{
		cells[d] = length;
	}
41

gsell's avatar
gsell committed
42 43 44 45
	void setAllCacheCellRanges(int length)
	{
		std::fill(cells, cells+Dim, length);
	}
46

gsell's avatar
gsell committed
47 48 49 50 51
	template<class C>
	void updateCacheInformation(
		ParticleSpatialLayout<T, Dim, Mesh, C > &PLayout
		)
	{
52
		for(unsigned int d = 0;d<Dim;++d)
gsell's avatar
gsell committed
53
			BoxParticleCachingPolicy<T,Dim,Mesh>::setCacheDimension(d, cells[d]*PLayout.getLayout().getMesh().get_meshSpacing(d));
54

gsell's avatar
gsell committed
55 56
		BoxParticleCachingPolicy<T,Dim,Mesh>:: updateCacheInformation(PLayout);
	}
57

gsell's avatar
gsell committed
58 59
	template<class C>
	void updateGhostParticles(
60
		IpplParticleBase< ParticleSpatialLayout<T,Dim,Mesh,C > > &PData,
gsell's avatar
gsell committed
61 62 63
		ParticleSpatialLayout<T, Dim, Mesh, C > &PLayout
		)
	{
64
		for(unsigned int d = 0;d<Dim;++d)
gsell's avatar
gsell committed
65
			BoxParticleCachingPolicy<T,Dim,Mesh>::setCacheDimension(d, cells[d]*PLayout.getLayout().getMesh().get_meshSpacing(d));
66

gsell's avatar
gsell committed
67 68 69 70 71 72 73 74
		BoxParticleCachingPolicy<T,Dim,Mesh>::updateGhostParticles(PData, PLayout);
	}
protected:
	~CellParticleCachingPolicy() {}
private:
	int cells[Dim];
};

75 76 77 78 79 80 81 82 83
#endif

// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End: