本文整理汇总了C++中FlowField::getNy方法的典型用法代码示例。如果您正苦于以下问题:C++ FlowField::getNy方法的具体用法?C++ FlowField::getNy怎么用?C++ FlowField::getNy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlowField
的用法示例。
在下文中一共展示了FlowField::getNy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main () {
std::cout << "Starting VTK test" << std::endl;
FlowField flowField ( 10, 10, 10 );
clock_t start = clock();
FLOAT velocity [3] = {1,1,1};
for (int k = 0; k < flowField.getNz() + 3; k++ ){
for (int j = 0; j < flowField.getNy() + 3; j++ ){
for (int i = 0; i < flowField.getNx() + 3; i++ ){
flowField.getPressure().getScalar(i,j,k) = (double) k;
flowField.getVelocity().setVector(velocity, i,j,k);
}
}
}
std::cout << "Initialization time: " << (double) (clock() - start) / CLOCKS_PER_SEC
<< std::endl;
start = clock();
Parameters parameters;
parameters.dx = 1;
parameters.dy = 1;
parameters.dz = 1;
VTKStencil stencil( "/tmp/some_file", parameters );
std::cout << "Stencil creation time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;
start = clock();
stencil.openFile ( flowField, 5.0/3 );
std::cout << "File-openning and grid data writing time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;
start = clock();
FieldIterator iterator( flowField, stencil );
iterator.iterateInnerCells();
std::cout << "Iteration time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;
start = clock();
stencil.write( flowField );
std::cout << "Writing time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;
stencil.closeFile();
}
示例2:
void VelocityBufferFillStencil::applyTopWall (FlowField & flowField, int i, int j, int k){
const int index = 3 * (i + (flowField.getNx()+3) * k);
_topBufferOut[ index ] = flowField.getVelocity().getVector(i, flowField.getNy()+1, k)[0];
_topBufferOut[index+1] = flowField.getVelocity().getVector(i, flowField.getNy() , k)[1];
_topBufferOut[index+2] = flowField.getVelocity().getVector(i, flowField.getNy()+1, k)[2];
}
示例3: applyTopWall
void VelocityBufferFillStencil::applyTopWall (FlowField & flowField, int i, int j){
_topBufferOut[ 2*i ] = flowField.getVelocity().getVector(i, flowField.getNy()+1)[0];
_topBufferOut[2*i+1] = flowField.getVelocity().getVector(i, flowField.getNy() )[1];
}
示例4: applyRightWall
void VelocityBufferFillStencil::applyRightWall (FlowField & flowField, int i, int j, int k){
const int index = 3 * (j + (flowField.getNy()+3) * k);
_rightBufferOut[ index ] = flowField.getVelocity().getVector(flowField.getNx(), j, k)[0];
_rightBufferOut[index+1] = flowField.getVelocity().getVector(flowField.getNx()+1, j, k)[1];
_rightBufferOut[index+2] = flowField.getVelocity().getVector(flowField.getNx()+1, j, k)[2];
}
示例5: if
PetscParallelManager::PetscParallelManager(FlowField & flowField, const Parameters & parameters):
ParallelManager<FlowField> (flowField, parameters),
_fillVelocityStencil(parameters, _leftBufferOut, _rightBufferOut, _bottomBufferOut,
_topBufferOut, _frontBufferOut, _backBufferOut),
_readVelocityStencil(parameters, _leftBufferIn, _rightBufferIn, _bottomBufferIn,
_topBufferIn, _frontBufferIn, _backBufferIn),
_fillPressureStencil(parameters, _leftBufferOut, _rightBufferOut, _bottomBufferOut,
_topBufferOut, _frontBufferOut, _backBufferOut),
_readPressureStencil(parameters, _leftBufferIn, _rightBufferIn, _bottomBufferIn,
_topBufferIn, _frontBufferIn, _backBufferIn),
_fillVelocityIterator(_flowField, parameters, _fillVelocityStencil, 1, 0),
_readVelocityIterator(_flowField, parameters, _readVelocityStencil, 1, 0),
_fillPressureIterator(_flowField, parameters, _fillPressureStencil, 1, 0),
_readPressureIterator(_flowField, parameters, _readPressureStencil, 1, 0)
{
// Allocate buffers and set number of pressure values
if (flowField.getDim() == 2){
_bufferSize[0] = 2 * (flowField.getNy() + 3); // Allocate space for all values
_bufferSize[1] = 2 * (flowField.getNx() + 3);
_pressureSize[0] = (flowField.getNy() + 3);
_pressureSize[1] = (flowField.getNx() + 3);
_leftBufferIn = new FLOAT[_bufferSize[0]];
_leftBufferOut = new FLOAT[_bufferSize[0]];
_rightBufferIn = new FLOAT[_bufferSize[0]];
_rightBufferOut = new FLOAT[_bufferSize[0]];
_bottomBufferIn = new FLOAT[_bufferSize[1]];
_bottomBufferOut = new FLOAT[_bufferSize[1]];
_topBufferIn = new FLOAT[_bufferSize[1]];
_topBufferOut = new FLOAT[_bufferSize[1]];
} else if (flowField.getDim() == 3) {
_bufferSize[0] = 3 * ((flowField.getNy()+3) * (flowField.getNz()+3));
_bufferSize[1] = 3 * ((flowField.getNx()+3) * (flowField.getNz()+3));
_bufferSize[2] = 3 * ((flowField.getNx()+3) * (flowField.getNy()+3));
_pressureSize[0] = (flowField.getNy()+3) * (flowField.getNz()+3);
_pressureSize[1] = (flowField.getNx()+3) * (flowField.getNz()+3);
_pressureSize[2] = (flowField.getNx()+3) * (flowField.getNy()+3);
_leftBufferIn = new FLOAT[_bufferSize[0]];
_leftBufferOut = new FLOAT[_bufferSize[0]];
_rightBufferIn = new FLOAT[_bufferSize[0]];
_rightBufferOut = new FLOAT[_bufferSize[0]];
_bottomBufferIn = new FLOAT[_bufferSize[1]];
_bottomBufferOut = new FLOAT[_bufferSize[1]];
_topBufferIn = new FLOAT[_bufferSize[1]];
_topBufferOut = new FLOAT[_bufferSize[1]];
_frontBufferIn = new FLOAT[_bufferSize[2]];
_frontBufferOut = new FLOAT[_bufferSize[2]];
_backBufferIn = new FLOAT[_bufferSize[2]];
_backBufferOut = new FLOAT[_bufferSize[2]];
}
}
示例6: write
void VTKStencil:: write ( FlowField & flowField, int timeStep ){
FieldIterator<FlowField> _it(flowField,_parameters,*this);
int i,j,k;
int Nx=flowField.getNx();
int Ny=flowField.getNy();
int Nz;
int dim=_parameters.geometry.dim;
if(dim == 2){Nz=0;}else{Nz=flowField.getNz();}
int cellx=flowField.getCellsX();
int celly=flowField.getCellsY();
int cellz;
if(dim == 2){cellz=3;}else{cellz=flowField.getCellsZ();}
//generate the file name
std::stringstream filename;
filename << this->_parameters.vtk.prefix << "_" << timeStep << ".vtk";
std::cout << filename.str() << std::endl;
// Open the file
std::ofstream vtkFile;
vtkFile.open(filename.str().c_str());
vtkFile << std::fixed << std::setprecision(6);
(this->_outputFile) = &vtkFile;
// Print file header
vtkFile << "# vtk DataFile Version 2.0" << std::endl;
vtkFile << "WS_1" << std::endl;
vtkFile << "ASCII" << "\n" << std::endl;
vtkFile << "DATASET STRUCTURED_GRID" << std::endl;
vtkFile << "DIMENSIONS " << Nx+1 << " " << Ny+1 << " " << Nz+1 << std::endl;
vtkFile << "POINTS " << (Nx+1)*(Ny+1)*(Nz+1) << " float" << std::endl;
// Print grids
for (k=2; k<cellz; k++){
for (j=2; j<celly; j++ ){
for(i=2; i<cellx; i++){
vtkFile << (_parameters.meshsize)->getPosX(i,j,k) << " " \
<< (_parameters.meshsize)->getPosY(i,j,k) << " " \
<< (_parameters.meshsize)->getPosZ(i,j,k) << std::endl;
}
}
}
// Output pressure field
vtkFile <<std::endl;
if(dim==2){
vtkFile << "CELL_DATA " << (cellx-3)*(celly-3)*(cellz-2) << std::endl;}
else{
vtkFile << "CELL_DATA " << (cellx-3)*(celly-3)*(cellz-3) << std::endl;}
vtkFile << "SCALARS pressure float 1" << std::endl;
vtkFile << "LOOKUP_TABLE default" << std::endl;
output_flag=0;
_it.iterate();
// Output velocity field
vtkFile << std::endl;
vtkFile << "VECTORS velocity float" << std::endl;
output_flag=1;
_it.iterate();
}