コード例 #1
0
    void LBInitPopUniform::createDenVel (real _rho0, Real3D _u0) {
			if (mpiWorld->rank()==0) {
				printf("Creating an initial configuration with uniform density %f and \nvelocity %f, %f, %f\n",
							 _rho0, _u0.getItem(0), _u0.getItem(1), _u0.getItem(2));
				printf("-------------------------------------\n");
			} else {
				// do nothing
			}
			
      real invCs2 = 1. / latticeboltzmann->getCs2();

      real invCs4 = invCs2*invCs2;
      real scalp, value;
			int _offset = latticeboltzmann->getHaloSkin();
			Int3D _Ni = latticeboltzmann->getMyNi();
			int _numVels = latticeboltzmann->getNumVels();	// number of velocities in the model
			
      // set initial velocity of the populations from Maxwell's distribution
#warning: check if taking care of OFFSET AT INITIALISATION () is needed
			for (int i = 0; i < _Ni.getItem(0); i++) {
      // test the damping of a sin-like initial velocities:
        real trace = _u0*_u0*invCs2;
        for (int j = 0; j < _Ni.getItem(1); j++) {
          for (int k = 0; k < _Ni.getItem(2); k++) {
            for (int l = 0; l < _numVels; l++) {
              scalp = _u0 * latticeboltzmann->getCi(l);
              value = 0.5 * latticeboltzmann->getEqWeight(l) * _rho0 * (2. + 2. * scalp * invCs2 + scalp * scalp * invCs4 - trace);
              latticeboltzmann->setLBFluid(Int3D(i,j,k),l,value);
              latticeboltzmann->setGhostFluid(Int3D(i,j,k),l,0.0);
            }
						
						/* fill in den and j values for real and halo regions */
						latticeboltzmann->setLBMom(Int3D(i,j,k),0,_rho0);
						latticeboltzmann->setLBMom(Int3D(i,j,k),1,_u0[0]*_rho0);
						latticeboltzmann->setLBMom(Int3D(i,j,k),2,_u0[1]*_rho0);
						latticeboltzmann->setLBMom(Int3D(i,j,k),3,_u0[2]*_rho0);
          }
        }
      }
//			latticeboltzmann->copyDenMomToHalo();
    }
コード例 #2
0
ファイル: LBInitPopWave.cpp プロジェクト: niktre/espressopp
    void LBInitPopWave::createDenVel (real _rho0, Real3D _u0) {
			if (mpiWorld->rank()==0) {
				printf("Creating an initial configuration with uniform density %f and \nharmonic velocity wave "
							 "v_x = %f, v_y = %f and v_z(x) = %f * sin(2 \\pi *i/Nx)\n",
							 _rho0, _u0.getItem(0), _u0.getItem(1), _u0.getItem(2));
				printf("-------------------------------------\n");
			} else {
				// do nothing
			}
			
      real invCs2 = 1. / latticeboltzmann->getCs2();

      real invCs4 = invCs2*invCs2;
      real scalp, value;
			int _offset = latticeboltzmann->getHaloSkin();
			Int3D _myPos = latticeboltzmann->getMyPos();
			Int3D _nodeGrid = latticeboltzmann->getNodeGrid();
			Int3D _Ni = latticeboltzmann->getNi();				// system size in lattice node
			Int3D _myNi = latticeboltzmann->getMyNi();		// my local nodes
			Int3D _globalNi = Int3D(0,0,0);								// index of the first real node in cpu in the global lattice
			int _numVels = latticeboltzmann->getNumVels();// number of velocities in the model
			
			for (int _dim = 0; _dim < 3; _dim++) {
				_globalNi[_dim] = floor(_myPos[_dim] * _Ni[_dim] / _nodeGrid[_dim]);
			}
			
      Real3D vel = _u0;

      // set initial velocity of the populations from Maxwell's distribution
      for (int i = _offset; i < _myNi.getItem(0) - _offset; i++) {
      // test the damping of a sin-like initial velocities:
        _u0 = Real3D(vel.getItem(0),vel.getItem(1),vel.getItem(2) * sin (2. * M_PI * (_globalNi[0] + i - _offset) / _Ni[0]));
        real trace = _u0*_u0*invCs2;
        for (int j = _offset; j < _myNi.getItem(1) - _offset; j++) {
          for (int k = _offset; k < _myNi.getItem(2) - _offset; k++) {
            for (int l = 0; l < _numVels; l++) {
              scalp = _u0 * latticeboltzmann->getCi(l);
              value = 0.5 * latticeboltzmann->getEqWeight(l) * _rho0 * (2. + 2. * scalp * invCs2 + scalp * scalp * invCs4 - trace);
              latticeboltzmann->setPops( Int3D(i,j,k), l, value );
              latticeboltzmann->setGhostFluid( Int3D(i,j,k), l, 0.0);
            }
						
						/* fill in den and j values for real and halo regions */
						latticeboltzmann->setLBMom(Int3D(i,j,k),0,_rho0);
						latticeboltzmann->setLBMom(Int3D(i,j,k),1,_u0[0]*_rho0);
						latticeboltzmann->setLBMom(Int3D(i,j,k),2,_u0[1]*_rho0);
						latticeboltzmann->setLBMom(Int3D(i,j,k),3,_u0[2]*_rho0);
          }
        }
      }
			latticeboltzmann->copyDenMomToHalo();
    }
コード例 #3
0
ファイル: Quaternion.hpp プロジェクト: Clemson-MSE/espressopp
 real getImagItem(int i) const { return unreal_part.getItem(i); }