8 #include <thrust/extrema.h> 9 #include <cusp/io/matrix_market.h> 17 template <
typename memoryType>
28 template <
typename memoryType>
34 int numUV = (nx-1)*ny + nx*(ny-1),
50 coeffsD.resize(numUV);
51 coeffs2.resize(numUV);
52 coeffs2D.resize(numUV);
56 pressure.resize(numP);
57 cusp::blas::fill(pressure, 0.0);
74 template <
typename memoryType>
98 template <
typename memoryType>
117 template <
typename memoryType>
125 cusp::array1d<real, memoryType> fluxes(nx*ny);
127 int minPosition = thrust::min_element(fluxes.begin(), fluxes.end()) - fluxes.begin(),
128 maxPosition = thrust::max_element(fluxes.begin(), fluxes.end()) - fluxes.begin();
129 real minFlux = fluxes[minPosition],
130 maxFlux = fluxes[maxPosition],
131 globalSum = thrust::reduce(fluxes.begin(), fluxes.end());
133 std::ofstream fluxInfoFile;
134 std::string folder = db[
"inputs"][
"caseFolder"].get<std::string>();
135 std::stringstream out;
136 out << folder <<
"/massFlux";
139 fluxInfoFile.open(out.str().c_str());
141 fluxInfoFile.open(out.str().c_str(), std::ios::out | std::ios::app);
143 fluxInfoFile << timeStep <<
'\t' << minFlux <<
'\t' << maxFlux <<
'\t' << globalSum << std::endl;
144 fluxInfoFile.close();
152 template <
typename memoryType>
166 template <
typename memoryType>
172 real dt = db[
"simulation"][
"dt"].get<
real>();
205 template <
typename memoryType>
210 int index = 5*(ny/2)*nx - nx - ny + 5*(nx/2) - 1 + 2;
211 int row = (ny/2)*nx+nx/2;
__global__ void updateRHS1(real *rhs1, int numUV, int *tags)
Update the RHS vector of the velocity system at forcing nodes.
virtual void writeData()
Writes the velocity, pressure, force and mass flux data at every save point.
void initialiseBodies()
Stores the parameters of the simulation and initializes the location and motion of each immersed bodi...
double real
Is a float or a double depending on the machine precision.
virtual void writeCommon()
Writes flow variables and position of body points into files.
virtual void initialise()
Initialize the vectors used in the simulation.
void initialiseCommon()
Initializes parameters common to all Navier-Stokes solvers.
void writeMassFluxInfo()
Prints the min, max and sum of the divergences of the velocity field in every cell of the domain...
A fully discrete formulation of the direct forcing method.
std::map< std::string, componentParameter > parameterDB
Map from a string to a componentParameter.
Stores information about the computational grid.
void initialiseArrays(int numQ, int numLambda)
Initializes all arrays required to solve the Navier-Stokes equations.
DirectForcingSolver(parameterDB *pDB=NULL, domain *dInfo=NULL)
Constructor. Initializes the simulation parameters and the domain info.
Declaration of the class DirectForcingSolver.
virtual void projectionStep()
Projects the pressure gradient on to the intermediate velocity field to obtain the divergence-free ve...
Implementation of the methods of the class DirectForcingSolver to update the right hand-side of the s...
void updateBodies()
Updates location and motion of each immersed body at current time.
Implementation of the methods of the class DirectForcingSolver to tag points near the immersed bounda...
virtual void projectionStep()
Projects the flux onto the divergence-free field.
void assembleMatrices()
Assembles matrices of the intermediate flux solver and the Poisson solver.
virtual void assembleRHS1()
Assembles the matrix rhs1 for DirectForcingSolver.
virtual void assembleRHS1()
Assembles the right hand-side of the system for the intermediate flux.
__global__ void forceX(real *f, real *q, real *rn, int *tags, int nx, int ny, real *dx, real *dy, real dt, real alpha, real nu)
Kernel not usable.
virtual void calculateForce()
Generic Navier-Stokes solver in the presence of immersed boundaries.
Solves the Navier-Stokes equations in a rectangular domain.
virtual void updateSolverState()
Updates the matrices every time the body is moved.
virtual void generateC()
Generates the right-hand side matrix in the Poisson step.