1 #ifndef __VISCID_UTIL_H__ 2 #define __VISCID_UTIL_H__ 24 const double * temperatureBuffer,
25 std::vector<double *> &tvBuffer,
28 const double bulkViscFac,
29 const double specificHeat,
30 const double prandtlNumber);
37 const size_t *numPointsPtr,
51 const std::vector<double> &gridMetrics,
54 const std::vector<double *> &tvBuffers,
55 const std::vector<double *> &velGradBuffers,
56 std::vector<double *> &tauBuffers);
72 const std::vector<double> &gridMetrics,
75 const std::vector<double *> &tvBuffers,
76 const std::vector<double *> &temperatureGradBuffers,
77 std::vector<double *> &heatFluxBuffers);
81 template<
typename Gr
idType,
typename StateType>
83 const std::vector<double> &inParams,
int threadId,
84 std::ostream *messageStream = NULL)
88 messageStream = &std::cout;
95 int numParams = inParams.size();
101 inletY = inParams[2];
105 const std::vector<size_t> &
gridSizes(inGrid.GridSizes());
106 const std::vector<size_t> &
bufferSizes(inGrid.BufferSizes());
110 const std::vector<double> &dX(inGrid.DX());
111 const std::vector<double> &readGridExtent(inGrid.PhysicalExtent());
113 if(numDim > 2 && numParams>3)
114 inletZ = inParams[3];
117 int nonDimensionalMode=0;
119 int paramHandle = inParamState.GetDataIndex(
"nonDimensional");
120 if(paramHandle >= 0){
122 const int *paramPtr = paramData.
Data<
int>();
123 nonDimensionalMode = *paramPtr;
125 nonDimensionalMode = 0;
130 double *gammaPtr = inParamState.template GetFieldBuffer<double>(
"gamma");
131 double *rhoRefPtr = inParamState.template GetFieldBuffer<double>(
"refRho");
132 double *refLengthPtr = inParamState.template GetFieldBuffer<double>(
"refLength");
133 double *presRefPtr = inParamState.template GetFieldBuffer<double>(
"refPressure");
134 double *tempRefPtr = inParamState.template GetFieldBuffer<double>(
"refTemperature");
136 double gamma = *gammaPtr;
137 double refLength = *refLengthPtr;
138 double refRho = *rhoRefPtr;
139 double refPressure = *presRefPtr;
140 double refTemperature = *tempRefPtr;
141 double sndSpdRef = sqrt(gamma*refPressure/refRho);
144 if(nonDimensionalMode == 1) {
148 }
else if (nonDimensionalMode ==2) {
156 double xMin = readGridExtent[0];
157 double xMax = readGridExtent[1];
158 double yMin = readGridExtent[2];
159 double yMax = readGridExtent[3];
163 zMin = readGridExtent[4];
164 zMax = readGridExtent[5];
178 if((inletY == yMin || inletY == yMax) ||
179 ((numDim > 2) && (inletZ == zMin || inletZ == zMax))) {
180 *messageStream <<
"Invalid inlet specification, point must live on one boundary only! " << std::endl;
183 *messageStream <<
"Initializing Poiseulle flow in the positive X-direction" << std::endl;
184 height = yMax - yMin;
185 length = xMax - xMin;
189 }
else if (inletX == xMax) {
191 if((inletY == yMin || inletY == yMax) ||
192 ((numDim > 2) && (inletZ == zMin || inletZ == zMax))) {
193 *messageStream <<
"Invalid inlet specification, point must live on one boundary only! " << std::endl;
196 *messageStream <<
"Initializing Poiseulle flow in the negative X-direction" << std::endl;
197 height = yMax - yMin;
198 length = xMax - xMin;
202 }
else if (inletY == yMin) {
204 if((inletX == xMin || inletX == xMax) ||
205 ((numDim > 2) && (inletZ == zMin || inletZ == zMax))) {
206 *messageStream <<
"Invalid inlet specification, point must live on one boundary only! " << std::endl;
209 *messageStream <<
"Initializing Poiseulle flow in the positive Y-direction" << std::endl;
211 height = xMax - xMin;
212 length = yMax - yMin;
215 }
else if (inletY == yMax) {
217 if((inletX == xMin || inletX == xMax) ||
218 ((numDim > 2) && (inletZ == zMin || inletZ == zMax))) {
219 *messageStream <<
"Invalid inlet specification, point must live on one boundary only! " << std::endl;
222 *messageStream <<
"Initializing Poiseulle flow in the negative Y-direction" << std::endl;
223 height = xMax - xMin;
224 length = yMax - yMin;
228 }
else if (inletZ == zMin) {
230 if(inletX == xMin || inletX == xMax || inletY == yMin || inletY == yMax) {
231 *messageStream <<
"Invalid inlet specification, point must live on one boundary only! " << std::endl;
234 *messageStream <<
"Initializing 3D Poiseulle flow in the positive Z-direction" << std::endl;
235 height = xMax - xMin;
237 length = zMax - zMin;
239 }
else if (inletZ == zMax) {
241 if(inletX == xMin || inletX == xMax || inletY == yMin || inletY == yMax) {
242 *messageStream <<
"Invalid inlet specification, point must live on one boundary only! " << std::endl;
245 *messageStream <<
"Initializing 3D Poiseulle flow in the positive Z-direction" << std::endl;
246 height = xMax - xMin;
248 length = zMax - zMin;
251 *messageStream <<
"Could not dermine flow direction from inlet specification" << std::endl;
258 *messageStream <<
"Poiseulle: Grid Sizes: (";
260 *messageStream <<
")" << std::endl
261 <<
"Poiseulle: Partition Interval: ";
262 partitionInterval.PrettyPrint(*messageStream);
263 *messageStream << std::endl <<
"Poiseulle: Partition Buffer Interval: ";
264 partitionBufferInterval.PrettyPrint(*messageStream);
265 *messageStream << std::endl;
266 *messageStream <<
"Poiseulle: pipe height " << height << std::endl;
268 *messageStream <<
"Poiseulle: pipe width " << width << std::endl;
269 *messageStream <<
"Poiseulle: pipe length " << length << std::endl;
271 const std::vector<double> &coordinateData(inGrid.CoordinateData());
273 int rhoHandle = inState.GetDataIndex(
"rho");
277 double *rhoPtr = rhoData.
Data<
double>();
281 int rhoVHandle = inState.GetDataIndex(
"rhoV");
285 double *rhoVPtr = rhoVData.
Data<
double>();
289 int rhoEHandle = inState.GetDataIndex(
"rhoE");
293 double *rhoEPtr = rhoEData.
Data<
double>();
299 rhoPtr[iPoint] = 0.0;
300 rhoEPtr[iPoint] = 0.0;
302 for(
int iDim = 0;iDim < numDim;iDim++){
305 rhoVPtr[iPoint+dimOffset] = 0.0;
310 double *RePtr = inParamState.template GetFieldBuffer<double>(
"refRe");
311 double *betaPtr = inParamState.template GetFieldBuffer<double>(
"beta");
312 double *powerPtr = inParamState.template GetFieldBuffer<double>(
"power");
314 double mu = (*betaPtr)*pow(refTemperature,(*powerPtr));
317 if(nonDimensionalMode == 1){
320 }
if(nonDimensionalMode == 2){
328 std::vector<double>
velocity(numDim,0);
329 double pLo = refPressure;
330 double pHi = pLo + deltaP;
332 double tempLo = refTemperature;
334 if(nonDimensionalMode == 1){
338 tempLo /= refTemperature;
339 }
else if (nonDimensionalMode == 2) {
341 pLo /= gamma*refPressure;
342 pHi /= gamma*refPressure;
343 tempLo /= (gamma-1)*refTemperature;
346 double rhoE = pLo/(gamma-1)/rho;
348 double dPdX = (pHi - pLo)/length;
351 *messageStream <<
"Poiseulle: Initial state" << std::endl;
352 *messageStream <<
"\t nonDimensional: " << nonDimensionalMode << std::endl;
354 *messageStream <<
"\t rho: " << rho << std::endl;
355 *messageStream <<
"\t Inlet pressure: " << pLo << std::endl;
356 *messageStream <<
"\t Outlet pressure: " << pHi << std::endl;
357 *messageStream <<
"\t temperature: " << tempLo << std::endl;
358 *messageStream <<
"\t rhoE: " << rhoE << std::endl;
359 *messageStream <<
"\t dPdX: " << dPdX << std::endl;
365 double pi = 3.14159265359;
366 size_t iStart = partitionBufferInterval[0].first;
367 size_t iEnd = partitionBufferInterval[0].second;
368 size_t jStart = partitionBufferInterval[1].first;
369 size_t jEnd = partitionBufferInterval[1].second;
374 kStart = partitionBufferInterval[2].first;
375 kEnd = partitionBufferInterval[2].second;
379 for(
size_t kIndex = kStart;kIndex <= kEnd;kIndex++){
380 size_t kBufferIndex = kIndex*nPlane;
381 size_t kPartIndex = 0;
384 kPartIndex = (kIndex - kStart) + partitionInterval[2].first;
385 z = kPartIndex*dX[2];
388 for(
size_t jIndex = jStart;jIndex <= jEnd;jIndex++){
389 size_t jkBufferIndex = kBufferIndex + jIndex*
bufferSizes[0];
390 size_t jPartIndex = (jIndex - jStart) + partitionInterval[1].first;
391 double y = jPartIndex*dX[1];
392 for(
size_t iIndex = iStart;iIndex <= iEnd;iIndex++){
393 size_t bufferIndex = jkBufferIndex + iIndex;
394 size_t iPartIndex = (iIndex - iStart) + partitionInterval[0].first;
395 double x = iPartIndex*dX[0];
397 double pressure = pLo;
398 if (direction == 1) {
399 pressure += dPdX*(xMax-
x);
400 if(x == xMin || x == xMax)
401 velocity[0] = Re*dPdX*y*(height-
y)/(2*mu);
404 }
else if (direction == -1) {
405 pressure += dPdX*(x-xMin);
406 if(x == xMin || x == xMax)
407 velocity[0] = Re*dPdX*y*(y-height)/(2*mu);
410 }
else if (direction == 2) {
411 pressure += dPdX*(yMax-
y);
412 if(y == yMin || y == yMax)
413 velocity[1] = Re*dPdX*x*(height-
x)/(2*mu);
416 }
else if (direction == -2) {
417 pressure += dPdX*(y-yMin);
418 if(y == yMin || y == yMax)
419 velocity[1] = Re*dPdX*x*(x-height)/(2*mu);
422 }
else if (direction == 3) {
423 pressure += dPdX*(zMax-z);
424 if(z == zMin || z == zMax) {
426 velocity[2] = Re*dPdX*x*(height-
x)/(2*mu);
433 for(
int n=1;n<nMax;n++){
434 double beta = (2*n-1)*pi/height;
435 sumTerm += sin(beta*x)/pow((2*n-1),3)*(sinh(beta*y)+sinh(beta*(width-y)))/sinh(beta*width);
437 sumTerm *= 4*dPdX*height*height/mu/pow(pi,3);
438 velocity[2] -= sumTerm;
443 }
else if (direction == -3) {
444 pressure += dPdX*(z-zMin);
445 if(z == zMin || z == zMax) {
447 velocity[2] = Re*dPdX*x*(x-height)/(2*mu);
454 for(
int n=1;n<nMax;n++){
455 double beta = (2*n-1)*pi/height;
456 sumTerm += sin(beta*x)/pow((2*n-1),3)*(sinh(beta*y)+sinh(beta*(width-y)))/sinh(beta*width);
458 sumTerm *= 4*dPdX*height*height/mu/pow(pi,3);
459 velocity[2] += sumTerm;
465 rhoPtr[bufferIndex] = rho;
466 rhoEPtr[bufferIndex] = pressure/(gamma-1);
467 for (
int iDim=0;iDim<numDim;iDim++){
468 rhoVPtr[bufferIndex+numPointsBuffer*iDim] = rhoPtr[bufferIndex]*velocity[iDim];
469 rhoEPtr[bufferIndex] += 0.5*rho*velocity[iDim]*velocity[iDim];
int ComputeTauBuffer(const pcpp::IndexIntervalType ®ionInterval, const std::vector< size_t > &bufferSize, int gridType, const std::vector< double > &gridMetrics, const std::vector< double > &gridJacobian, const double &Re, const std::vector< double *> &tvBuffers, const std::vector< double *> &velGradBuffers, std::vector< double *> &tauBuffers)
void size_t int size_t int size_t int int int int double int int double double *void size_t int size_t int int int int int double int size_t size_t size_t double double *void size_t int size_t int size_t size_t int double int double double *void size_t size_t * bufferSize
void const size_t const size_t const size_t const int const int const double const double const double * rhoVBuffer
int ComputeHeatFluxBuffer(const pcpp::IndexIntervalType ®ionInterval, const std::vector< size_t > &bufferSize, int gridType, const std::vector< double > &gridMetrics, const std::vector< double > &gridJacobian, const double &Re, const std::vector< double *> &tvBuffers, const std::vector< double *> &temperatureGradBuffers, std::vector< double *> &heatFluxBuffers)
void const size_t const size_t * gridSizes
void const size_t const size_t const size_t const double const double double * y
simulation::grid::subregion GridRegionType
void const size_t const size_t const size_t const int const int * gridType
void const size_t const size_t const size_t const int const double const int const double * velocity
void const size_t const size_t const size_t const double const double * x
int ComputeTVBuffer(const int *numDimPtr, const size_t *bufferSize, const size_t *numPointsPtr, const size_t *bufferInterval, const double *rhoBuffer, const double *rhoVBuffer, const double *rhoEBuffer, double *pressureBuffer, double *tempBuffer, double *rhom1Buffer, double *velBuffer)
void const size_t const size_t const size_t const int const int const double const double const double const double * rhoEBuffer
void const size_t const size_t const size_t const int const int const double const double const double const double const double const double * pressureBuffer
int ComputeTVBufferPower(const pcpp::IndexIntervalType ®ionInterval, const std::vector< size_t > &bufferSize, const double *temperatureBuffer, std::vector< double *> &tvBuffer, const double beta, const double power, const double bulkViscFac, const double specificHeat, const double prandtlNumber)
Compute transport coefficients using the power law.
void const size_t const size_t const size_t const int const double * gridJacobian
void const size_t const size_t * bufferSizes
void size_t int size_t int size_t int int int int double int int double double *void size_t int size_t int int int int int double int size_t size_t size_t double double *void size_t int size_t int size_t size_t int double int double double *void size_t size_t size_t * bufferInterval
int InitializePoiseuille(const GridType &inGrid, StateType &inState, StateType &inParamState, const std::vector< double > &inParams, int threadId, std::ostream *messageStream=NULL)
void const size_t const size_t const size_t const int const int const double const double * rhoBuffer
Simple Block Structured Mesh object.
void InitSimple(const ContainerType &inSize)
void const size_t * numPointsBuffer