24#ifndef FLUID_HDF5_IO_HH
25#define FLUID_HDF5_IO_HH
29#include "palabos3D.hh"
41 hid_t sid = H5Screate_simple(4,dim,NULL);
42 hid_t plist_id = H5Pcreate (H5P_DATASET_CREATE);
43 H5Pset_chunk(plist_id, 4, chunk);
44 H5Pset_deflate(plist_id, 7);
45 hid_t did = H5Dcreate2(file_id,name.c_str(),H5T_NATIVE_FLOAT,sid,H5P_DEFAULT,plist_id,H5P_DEFAULT);
46 H5Dwrite(did,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,output);
51template<
template<
class U>
class DD>
61 return BlockDomain::bulk;
69 for (
pluint i = 0; i < modified.size(); i++) {
70 modified[i] = modif::nothing;
76 int id = global::mpi().getRank();
77 ablock =
dynamic_cast<BlockLattice3D<T,DD>*
>(blocks[0]);
91 file_id = H5Fcreate(fileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
92 H5LTset_attribute_double (file_id,
"/",
"dx", &
dx, 1);
93 H5LTset_attribute_double (file_id,
"/",
"dt", &
dt, 1);
94 long int iterHDF5=
iter;
95 H5LTset_attribute_long (file_id,
"/",
"iteration", &iterHDF5, 1);
96 H5LTset_attribute_int (file_id,
"/",
"processorId", &
id, 1);
98 hsize_t Nx = domain.x1 - domain.x0+1 +2;
99 hsize_t Ny = domain.y1 - domain.y0+1 +2;
100 hsize_t Nz = domain.z1 - domain.z0+1 +2;
103 int ncells = Nx*Ny*Nz;
104 Dot3D rp_temp = blocks[0]->getLocation();
105 int subdomainSize[] = {int(Nz), int(Ny), int(Nx)};
106 float dxdydz[3] = {1.,1.,1.};
107 float relativePosition[3] = {float(rp_temp.z+domain.z0-1.5),
108 float(rp_temp.y+domain.y0-1.5),
109 float(rp_temp.x+domain.x0-1.5)};
112 relativePosition[0] *= param::dx;
113 relativePosition[1] *= param::dx;
114 relativePosition[2] *= param::dx;
115 dxdydz[0] = param::dx;
116 dxdydz[1] = param::dx;
117 dxdydz[2] = param::dx;
120 H5LTset_attribute_int (file_id,
"/",
"numberOfCells", &ncells, 1);
121 H5LTset_attribute_int (file_id,
"/",
"subdomainSize", subdomainSize, 3);
122 H5LTset_attribute_float(file_id,
"/",
"relativePosition", relativePosition, 3);
123 H5LTset_attribute_float(file_id,
"/",
"dxdydz",dxdydz,3);
127 chunk[2] = 1000 < Nx ? 1000 : Nx;
128 chunk[1] = 1000 < Ny ? 1000 : Ny;
129 chunk[0] = 1000 < Nz ? 1000 : Nz;
139 switch(outputVariable) {
162 name =
"BindingSites";
167 name =
"InteriorPoints";
186 name =
"ShearStress";
216 float * output =
new float [(*nCells)*3];
223 ablock->get(iX,iY,iZ).computeVelocity(vel);
225 output[n+1] = vel[1];
226 output[n+2] = vel[2];
233 for (
unsigned int i = 0 ; i < (*nCells)*3 ; i++) {
234 output[i] = output[i]*param::dx/param::dt;
242 float * output =
new float [(*nCells)*3];
249 output[n] =
ablock->get(iX,iY,iZ).external.data[0];
250 output[n+1] =
ablock->get(iX,iY,iZ).external.data[1];
251 output[n+2] =
ablock->get(iX,iY,iZ).external.data[2];
258 for (
unsigned int i = 0 ; i < (*nCells)*3 ; i++) {
259 output[i] = output[i]*param::df;
267 float * output =
new float [(*nCells)];
273 output[n] =
ablock->get(iX,iY,iZ).computeDensity();
280 for (
unsigned int i = 0 ; i < (*nCells) ; i++) {
281 output[i] = output[i]*(param::df/(param::dx*param::dx));
289 float * output =
new float [(*nCells)];
295 if (
ablock->get(iX,iY,iZ).getDynamics().isBoundary()) {
308 float * output =
new float [(*nCells)];
310 pcout <<
"(FluidHdf5) (Error) OUTPUT_BINDING_SITES requested, but binding sites not used, outputting a zero field" << endl;
334 float * output =
new float [(*nCells)];
336 pcout <<
"(FluidHdf5) (Error) OUTPUT_INTERIOR_POINTS requested, but interior viscosity not used, outputting a zero field" << endl;
355 float * output =
new float [(*nCells)];
361 output[n] =
ablock->get(iX,iY,iZ).getDynamics().getOmega();
368 for (
unsigned int i = 0 ; i < (*nCells) ; i++) {
369 output[i] = output[i]*(param::df/(param::dx*param::dx));
377 float * output =
new float [(*nCells)];
378 memset(output, 0,
sizeof(
float)*(*
nCells));
380 vector<HemoCellParticle*> found;
389 const Dot3D tmpDot =
ablock->getLocation();
390 iX =
plint((particle->sv.position[0]-tmpDot.x)+0.5);
391 iY =
plint((particle->sv.position[1]-tmpDot.y)+0.5);
392 iZ =
plint((particle->sv.position[2]-tmpDot.z)+0.5);
394 output[(iX)+(iY)*Ystride+(iZ)*Zstride] += 1;
398 for (
unsigned int i = 0 ; i < (*nCells) ; i++) {
399 output[i] *=
cellfields[name]->volumeFractionOfLspPerNode;
407 float * output =
new float [(*nCells)*6];
409 plb::Array<T,6> stress;
415 ablock->get(iX,iY,iZ).computeShearStress(stress);
417 output[n] = stress[0];
418 output[n+1] = stress[1];
419 output[n+2] = stress[2];
420 output[n+3] = stress[3];
421 output[n+4] = stress[4];
422 output[n+5] = stress[5];
429 for (
unsigned int i = 0 ; i < (*nCells)*6 ; i++) {
430 output[i] = output[i]*(param::df/(param::dx*param::dx));
438 float * output =
new float [(*nCells)*9];
440 plb::Array<T,9> shearrate;
441 plb::Array<T,3> velp1;
442 plb::Array<T,3> veln1;
443 plb::Array<T,3> velp2;
444 plb::Array<T,3> veln2;
445 plb::Array<T,3> velp3;
446 plb::Array<T,3> veln3;
453 ablock->get(iX+1,iY,iZ).computeVelocity(velp1);
454 ablock->get(iX-1,iY,iZ).computeVelocity(veln1);
457 ablock->get(iX,iY+1,iZ).computeVelocity(velp2);
458 ablock->get(iX,iY-1,iZ).computeVelocity(veln2);
461 ablock->get(iX,iY,iZ+1).computeVelocity(velp3);
462 ablock->get(iX,iY,iZ-1).computeVelocity(veln3);
464 shearrate[0] = (velp1[0]-veln1[0])/2;
465 shearrate[3] = (velp1[1]-veln1[1])/2;
466 shearrate[6] = (velp1[2]-veln1[2])/2;
467 shearrate[1] = (velp2[0]-veln2[0])/2;
468 shearrate[4] = (velp2[1]-veln2[1])/2;
469 shearrate[7] = (velp2[2]-veln2[2])/2;
470 shearrate[2] = (velp3[0]-veln3[0])/2;
471 shearrate[5] = (velp3[1]-veln3[1])/2;
472 shearrate[8] = (velp3[2]-veln3[2])/2;
474 output[n] = shearrate[0];
475 output[n+1] = shearrate[1];
476 output[n+2] = shearrate[2];
477 output[n+3] = shearrate[3];
478 output[n+4] = shearrate[4];
479 output[n+5] = shearrate[5];
480 output[n+6] = shearrate[6];
481 output[n+7] = shearrate[7];
482 output[n+8] = shearrate[8];
489 for (
unsigned int i = 0 ; i < (*nCells)*9 ; i++) {
490 output[i] = output[i]*(1/(param::dt));
498 float * output =
new float [(*nCells)*6];
501 std::unique_ptr<TensorField3D<T,6> > strainrate (computeStrainRateFromStress(*
ablock));
503 std::unique_ptr<ScalarField3D<T> > shearrate (computeSymmetricTensorNorm(*strainrate));
512 if ((iX <
fluid.getBoundingBox().x0-2) || (iX >
fluid.getBoundingBox().x1+2) ||
513 (iY <
fluid.getBoundingBox().y0-2) || (iY >
fluid.getBoundingBox().y1+2) ||
514 (iZ <
fluid.getBoundingBox().z0-2) || (iZ >
fluid.getBoundingBox().z1+2) )
525 output[n] = strainrate->get(iX,iY,iZ)[0];
526 output[n+1] = strainrate->get(iX,iY,iZ)[1];
527 output[n+2] = strainrate->get(iX,iY,iZ)[2];
528 output[n+3] = strainrate->get(iX,iY,iZ)[3];
529 output[n+4] = strainrate->get(iX,iY,iZ)[4];
530 output[n+5] = strainrate->get(iX,iY,iZ)[5];
538 for (
unsigned int i = 0 ; i < (*nCells)*6 ; i++) {
539 output[i] = output[i]*(1/(param::dt));
Definition hemoCellFields.h:53
unsigned int size()
Get the number of celltypes.
Definition hemoCellFields.cpp:148
HemoCell & hemocell
Reference to parent.
Definition hemoCellFields.h:169
Definition hemoCellParticleField.h:39
plb::ScalarField3D< bool > * bindingField
Definition hemoCellParticleField.h:206
pluint atomicBlockId
Definition hemoCellParticleField.h:136
plb::ScalarField3D< T > * interiorViscosityField
Definition hemoCellParticleField.h:192
virtual void findParticles(plb::Box3D domain, std::vector< HemoCellParticle * > &found)
plb::Box3D localDomain
Definition hemoCellParticleField.h:202
Definition hemoCellParticle.h:40
bool outputInSiUnits
Specify whether the output is in SI or LBM units.
Definition hemocell.h:201
bool partOfpreInlet
Definition hemocell.h:228
Definition FluidHdf5IO.hh:53
float * outputShearStress()
Definition FluidHdf5IO.hh:406
HemoCellParticleField * particlefield
Definition FluidHdf5IO.hh:555
string identifier
Definition FluidHdf5IO.hh:550
double dx
Definition FluidHdf5IO.hh:551
BlockLattice3D< T, DD > * ablock
Definition FluidHdf5IO.hh:554
plint iter
Definition FluidHdf5IO.hh:549
float * outputInteriorPoints()
Definition FluidHdf5IO.hh:333
float * outputCellDensity(string name)
Definition FluidHdf5IO.hh:376
WriteFluidField * clone() const
Definition FluidHdf5IO.hh:64
double dt
Definition FluidHdf5IO.hh:552
BlockDomain::DomainT appliesTo() const
Definition FluidHdf5IO.hh:60
float * outputShearRate()
Definition FluidHdf5IO.hh:437
hsize_t * nCells
Definition FluidHdf5IO.hh:557
HemoCellFields & cellfields
Definition FluidHdf5IO.hh:547
float * outputOmega()
Definition FluidHdf5IO.hh:354
float * outputStrainRate()
Definition FluidHdf5IO.hh:497
~WriteFluidField()
Definition FluidHdf5IO.hh:58
float * outputDensity()
Definition FluidHdf5IO.hh:266
void getTypeOfModification(vector< modif::ModifT > &modified) const
Definition FluidHdf5IO.hh:68
void processGenericBlocks(Box3D domain, vector< AtomicBlock3D * > blocks)
Definition FluidHdf5IO.hh:74
float * outputBoundary()
Definition FluidHdf5IO.hh:288
float * outputForce()
Definition FluidHdf5IO.hh:241
vector< int > & outputVariables
Definition FluidHdf5IO.hh:558
int blockid
Definition FluidHdf5IO.hh:556
MultiBlock3D & fluid
Definition FluidHdf5IO.hh:548
float * outputBindingSites()
Definition FluidHdf5IO.hh:307
float * outputVelocity()
Definition FluidHdf5IO.hh:215
Box3D * odomain
Definition FluidHdf5IO.hh:553
WriteFluidField(HemoCellFields &cellfields_, MultiBlock3D &fluid_, plint iter_, string identifier_, T dx_, T dt_, vector< int > &outputVariables_)
Definition FluidHdf5IO.hh:55
#define OUTPUT_VELOCITY
Definition constant_defaults.h:99
#define OUTPUT_SHEAR_STRESS
Definition constant_defaults.h:104
#define OUTPUT_INTERIOR_POINTS
Definition constant_defaults.h:109
#define OUTPUT_STRAIN_RATE
Definition constant_defaults.h:111
#define OUTPUT_FORCE
Definition constant_defaults.h:90
double T
Definition constant_defaults.h:118
#define OUTPUT_CELL_DENSITY
Definition constant_defaults.h:103
#define OUTPUT_DENSITY
Definition constant_defaults.h:100
#define OUTPUT_BINDING_SITES
Definition constant_defaults.h:108
#define OUTPUT_OMEGA
Definition constant_defaults.h:106
#define OUTPUT_SHEAR_RATE
Definition constant_defaults.h:110
long int plint
Definition constant_defaults.h:127
#define OUTPUT_BOUNDARY
Definition constant_defaults.h:107
long unsigned int pluint
Definition constant_defaults.h:130
std::string zeroPadNumber(int num, int w)
Definition genericFunctions.cpp:112
long long unsigned int hsize_t
Definition FluidHdf5IO.h:34
void outputHDF5(hsize_t *dim, hsize_t *chunk, hid_t &file_id, string &name, float *output)
Definition FluidHdf5IO.hh:36