Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
5690a465
Commit
5690a465
authored
Jun 18, 2015
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
allocate plans and memory
parent
0c4ee682
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/fluid_solver.cpp
+69
-27
69 additions, 27 deletions
src/fluid_solver.cpp
src/fluid_solver.hpp
+7
-1
7 additions, 1 deletion
src/fluid_solver.hpp
with
76 additions
and
28 deletions
src/fluid_solver.cpp
+
69
−
27
View file @
5690a465
...
...
@@ -21,44 +21,86 @@
#include
"fluid_solver.hpp"
///*****************************************************************************/
///* generic definitions, empty by design */
//
//template <class rnumber>
//fluid_solver<rnumber>::fluid_solver()
//{}
//template <class rnumber>
//fluid_solver<rnumber>::~fluid_solver()
//{}
//template <class rnumber>
//void fluid_solver<rnumber>::step()
//{}
///*****************************************************************************/
#include
"fftwf_tools.hpp"
/*****************************************************************************/
/* macro for specializations to numeric types compatible with FFTW */
#define FLUID_SOLVER_DEFINITIONS(
X
, R, C) \
#define FLUID_SOLVER_DEFINITIONS(
FFTW
, R, C) \
\
template<> \
fluid_solver<R>::fluid_solver() \
fluid_solver<R>::fluid_solver( \
int nx, \
int ny, \
int nz) \
{ \
this->c2r_vorticity = new X(plan);\
this->r2c_vorticity = new X(plan);\
this->c2r_velocity = new X(plan);\
this->r2c_velocity = new X(plan);\
FFTW(get_descriptors_3D)(nz, ny, nx, &this->fr, &this->fc);\
this->cvorticity = FFTW(alloc_complex)(this->fc->local_size*3);\
this->cvelocity = FFTW(alloc_complex)(this->fc->local_size*3);\
this->rvorticity = FFTW(alloc_real)(this->fc->local_size*6);\
this->rvelocity = FFTW(alloc_real)(this->fc->local_size*6);\
\
this->c2r_vorticity = new FFTW(plan);\
this->r2c_vorticity = new FFTW(plan);\
this->c2r_velocity = new FFTW(plan);\
this->r2c_velocity = new FFTW(plan);\
\
ptrdiff_t sizes[] = {this->fr->sizes[0], \
this->fr->sizes[1], \
this->fr->sizes[2]};\
\
*(FFTW(plan)*)this->c2r_vorticity = FFTW(mpi_plan_many_dft_c2r)( \
3, sizes, 3, \
FFTW_MPI_DEFAULT_BLOCK, \
FFTW_MPI_DEFAULT_BLOCK, \
this->cvorticity, this->rvorticity, \
MPI_COMM_WORLD, \
FFTW_ESTIMATE); \
\
*(FFTW(plan)*)this->r2c_vorticity = FFTW(mpi_plan_many_dft_r2c)( \
3, sizes, 3, \
FFTW_MPI_DEFAULT_BLOCK, \
FFTW_MPI_DEFAULT_BLOCK, \
this->rvorticity, this->cvorticity, \
MPI_COMM_WORLD, \
FFTW_ESTIMATE); \
\
*(FFTW(plan)*)this->c2r_velocity = FFTW(mpi_plan_many_dft_c2r)( \
3, sizes, 3, \
FFTW_MPI_DEFAULT_BLOCK, \
FFTW_MPI_DEFAULT_BLOCK, \
this->cvelocity, this->rvelocity, \
MPI_COMM_WORLD, \
FFTW_ESTIMATE); \
\
*(FFTW(plan)*)this->r2c_velocity = FFTW(mpi_plan_many_dft_r2c)( \
3, sizes, 3, \
FFTW_MPI_DEFAULT_BLOCK, \
FFTW_MPI_DEFAULT_BLOCK, \
this->rvelocity, this->cvelocity, \
MPI_COMM_WORLD, \
FFTW_ESTIMATE); \
} \
\
template<> \
fluid_solver<R>::~fluid_solver() \
{ \
delete (X(plan)*)this->c2r_vorticity;\
delete (X(plan)*)this->r2c_vorticity;\
delete (X(plan)*)this->c2r_velocity ;\
delete (X(plan)*)this->r2c_velocity ;\
FFTW(destroy_plan)(*(FFTW(plan)*)this->c2r_vorticity);\
FFTW(destroy_plan)(*(FFTW(plan)*)this->r2c_vorticity);\
FFTW(destroy_plan)(*(FFTW(plan)*)this->c2r_velocity );\
FFTW(destroy_plan)(*(FFTW(plan)*)this->r2c_velocity );\
\
delete (FFTW(plan)*)this->c2r_vorticity;\
delete (FFTW(plan)*)this->r2c_vorticity;\
delete (FFTW(plan)*)this->c2r_velocity ;\
delete (FFTW(plan)*)this->r2c_velocity ;\
\
FFTW(free)(this->cvorticity);\
FFTW(free)(this->rvorticity);\
FFTW(free)(this->cvelocity);\
FFTW(free)(this->rvelocity);\
} \
\
template<> \
...
...
@@ -70,10 +112,10 @@ void fluid_solver<R>::step() \
/*****************************************************************************/
/* now actually use the macro defined above */
FLUID_SOLVER_DEFINITIONS
(
FFTW_MANGLE_DOUBLE
,
double
,
fftw_complex
)
FLUID_SOLVER_DEFINITIONS
(
FFTW_MANGLE_FLOAT
,
float
,
fftwf_complex
)
FLUID_SOLVER_DEFINITIONS
(
FFTW_MANGLE_LONG_DOUBLE
,
long
double
,
fftwl_complex
)
FLUID_SOLVER_DEFINITIONS
(
FFTW_MANGLE_QUAD
,
__float128
,
fftwq_complex
)
FLUID_SOLVER_DEFINITIONS
(
FFTW_MANGLE_DOUBLE
,
double
,
fftw_complex
)
//FLUID_SOLVER_DEFINITIONS(FFTW_MANGLE_LONG_DOUBLE, long double, fftwl_complex)
//FLUID_SOLVER_DEFINITIONS(FFTW_MANGLE_QUAD, __float128, fftwq_complex)
/*****************************************************************************/
...
...
...
...
This diff is collapsed.
Click to expand it.
src/fluid_solver.hpp
+
7
−
1
View file @
5690a465
...
...
@@ -56,7 +56,13 @@ class fluid_solver
void
*
c2r_velocity
;
void
*
r2c_velocity
;
fluid_solver
();
/* parameters */
rnumber
nu
;
/* methods */
fluid_solver
(
int
nx
,
int
ny
,
int
nz
);
~
fluid_solver
();
void
step
();
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment