Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
7f778463
Commit
7f778463
authored
Mar 30, 2015
by
Quentin Khan
Browse files
made loadFMAANdRunFMM work with basic FFmmAlgorithm
parent
2d3595d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Examples/loadFMAAndRunFMM.cpp
View file @
7f778463
...
...
@@ -14,43 +14,54 @@
// "http://www.gnu.org/licenses".
// ===================================================================================
#include
<fstream>
#include
<memory>
#include
<string>
//#include "Utils/FMath.hpp"
//#include "Utils/FParameters.hpp"
//#include "Utils/FParameterNames.hpp"
#include
"Files/FFmaGenericLoader.hpp"
#include
"Core/FFmmAlgorithm.hpp"
#include
"Kernels/Chebyshev/FChebSymKernel.hpp"
#include
"Files/FRandomLoader.hpp"
#include
"Containers/FOctree.hpp"
#include
"Components/FBasicCell.hpp"
// Cell
//#include "Components/FBasicCell.hpp"
//#include "Kernels/Chebyshev/FChebCell.hpp"
#include
"Components/FTestCell.hpp"
// Particle Container
//#include "Components/FBasicParticleContainer.hpp"
#include
"Components/FTestParticleContainer.hpp"
// Leaf
#include
"Components/FSimpleLeaf.hpp"
#include
"Components/FBasicParticleContainer.hpp"
#include
"FFmmAlgorithmThreadBalanced.hpp"
#include
"
loadFMAAndRunFMMArgs
.hpp"
#include
"
loadFMAAndRunFMMUti
ls.hpp"
// Kernel
//
#include "
Kernels/Chebyshev/FChebSymKernel
.hpp"
#include
"
Components/FTestKerne
ls.hpp"
#include
"FChebBalanceSymKernel.hpp"
// Algorithm
#include
"Core/FFmmAlgorithm.hpp"
#include
"FFmmAlgorithmThreadBalanced.hpp"
// Other
#include
"CostZones.hpp"
#include
"loadFMAAndRunFMMArgs.hpp"
#include
"loadFMAAndRunFMMUtils.hpp"
// last include, to shorten main file
#define ORDER 7
using
CellClass
=
FCostCell
;
using
ContainerClass
=
F
Basic
ParticleContainer
<
0
>
;
using
CellClass
=
FCostCell
<
FTestCell
>
;
using
ContainerClass
=
F
Test
ParticleContainer
;
using
LeafClass
=
FSimpleLeaf
<
ContainerClass
>
;
using
OctreeClass
=
FOctree
<
CellClass
,
ContainerClass
,
LeafClass
>
;
using
MatrixKernelClass
=
FInterpMatrixKernelR
;
using
BalanceKernelClass
=
FChebBalanceSymKernel
<
CellClass
,
ContainerClass
,
MatrixKernelClass
,
5
,
MatrixKernelClass
,
ORDER
,
OctreeClass
>
;
// using KernelClass = FChebSymKernel<CellClass, ContainerClass,
// MatrixKernelClass, 5,
// OctreeClass>;
template
<
template
<
typename
...
>
class
T
>
using
AlgoClass
=
T
<
OctreeClass
,
CellClass
,
ContainerClass
,
BalanceKernelClass
,
LeafClass
>
;
using
KernelClass
=
FTestKernels
<
CellClass
,
ContainerClass
>
;
template
<
template
<
typename
...
>
class
T
,
class
KernelClassT
>
using
FmmClass
=
T
<
OctreeClass
,
CellClass
,
ContainerClass
,
KernelClassT
,
LeafClass
>
;
const
FReal
epsilon
=
1e-4
;
...
...
@@ -58,33 +69,56 @@ const FReal epsilon = 1e-4;
int
main
(
int
argc
,
char
**
argv
)
{
// Handle arguments
loadFMAAndRunFMMArgs
args
(
argc
,
argv
);
/* Creating tree and insterting particles *********************************/
FFmaGenericLoader
loader
(
args
.
inFileName
().
c_str
());
//FRandomLoader loader(20, 1, FPoint(0.5,0.5,0.5), 1);
OctreeClass
tree
(
args
.
treeHeight
(),
args
.
subTreeHeight
(),
loader
.
getBoxWidth
(),
loader
.
getCenterOfBox
());
loadTree
(
tree
,
loader
);
BalanceKernelClass
kernel
(
&
tree
,
epsilon
);
AlgoClass
<
FFmmAlgorithm
>
costAlgo
(
&
tree
,
&
kernel
);
/**************************************************************************/
/* Compute the cost of each tree cell *************************************/
BalanceKernelClass
balanceKernel
(
&
tree
,
epsilon
);
FmmClass
<
FFmmAlgorithm
,
BalanceKernelClass
>
costAlgo
(
&
tree
,
&
balanceKernel
);
costAlgo
.
execute
();
if
(
args
.
verboseLevel
()
>
1
)
{
k
ernel
.
printResults
(
std
::
cout
);
balanceK
ernel
.
printResults
(
std
::
cout
);
}
/**************************************************************************/
/* Run the costzone algorithm *********************************************/
CostZones
<
OctreeClass
,
CellClass
>
costzones
(
&
tree
,
args
.
zoneCount
());
costzones
.
run
();
writeZones
(
args
,
costzones
);
/**************************************************************************/
/* Run the balanced algorithm *********************************************/
std
::
cout
<<
"Running kernel"
<<
std
::
endl
;
KernelClass
computeKernel
;
FmmClass
<
FFmmAlgorithmThreadBalanced
,
KernelClass
>
fmmAlgo
(
&
tree
,
&
computeKernel
,
costzones
.
getZoneBounds
());
//FmmClass<FFmmAlgorithm, KernelClass> fmmAlgo(&tree, &computeKernel);
AlgoClass
<
FFmmAlgorithmThreadBalanced
>
fmmAlgo
(
&
tree
,
&
kernel
,
costzones
.
getZoneBounds
());
fmmAlgo
.
execute
();
/**************************************************************************/
/* Check the results ******************************************************/
ValidateFMMAlgo
<
OctreeClass
,
CellClass
,
ContainerClass
,
LeafClass
>
(
&
tree
);
return
EXIT_SUCCESS
;
}
...
...
Examples/loadFMAAndRunFMMArgs.hpp
View file @
7f778463
...
...
@@ -24,7 +24,11 @@ class loadFMAAndRunFMMArgs {
TCLAP
::
LinuxOutput
_cmdFormat
;
TCLAP
::
BashCompletion
::
Visitor
_compVistor
;
TCLAP
::
BashCompletion
::
Visitor
_compVistor
{
&
_cmd
,
{
{
&
_inFileName
,
{
TCLAP
::
BashCompletion
::
FILE
,
"!*.fma"
}},
{
&
_outFileExt
,
{
"csv"
}}}};
TCLAP
::
SwitchArg
_compArg
{
""
,
"completion"
,
...
...
@@ -82,11 +86,7 @@ public:
return
ext
;
}
loadFMAAndRunFMMArgs
(
int
argc
,
char
**
argv
)
:
_compVistor
(
argc
,
argv
,
&
_cmd
,
{
{
&
_inFileName
,{
TCLAP
::
BashCompletion
::
FILE
,
"!*.fma"
}},
{
&
_outFileExt
,
{
"csv"
}}}
){
loadFMAAndRunFMMArgs
(
int
argc
,
char
**
argv
)
{
int
columns
=
80
;
struct
winsize
w
;
if
(
ioctl
(
0
,
TIOCGWINSZ
,
&
w
)
==
0
)
...
...
Examples/loadFMAAndRunFMMUtils.hpp
View file @
7f778463
#ifndef _LOADFMAANDRUNFMMUTILS_HPP_
#define _LOADFMAANDRUNFMMUTILS_HPP_
#include
"CostZones.hpp"
#include
<fstream>
#include
<memory>
#include
<assert.h>
/**
...
...
@@ -16,10 +17,10 @@
template
<
class
OctreeClass
,
class
CellClass
>
void
writeZones
(
const
loadFMAAndRunFMMArgs
&
args
,
const
CostZones
<
OctreeClass
,
CellClass
>&
costzones
)
{
std
::
string
outFileBaseName
=
args
.
outFileName
();
std
::
string
outFileExt
=
args
.
outFileExt
();
int
verboseLevel
=
args
.
verboseLevel
();
int
treeHeight
=
args
.
treeHeight
();
const
std
::
string
outFileBaseName
=
args
.
outFileName
();
const
std
::
string
outFileExt
=
args
.
outFileExt
();
const
int
verboseLevel
=
args
.
verboseLevel
();
const
int
treeHeight
=
args
.
treeHeight
();
auto
zones
=
costzones
.
getZones
();
int
zoneCount
=
zones
.
size
();
//args.zoneCount();
...
...
@@ -65,6 +66,7 @@ void writeZones(const loadFMAAndRunFMMArgs& args, const CostZones <OctreeClass,C
}
}
/**
* \brief Loads a tree from a loader.
* \param tree The the to load into.
...
...
@@ -78,7 +80,19 @@ void loadTree(OctreeClass& tree, FFmaGenericLoader& loader)
// insertion
for
(
int
idxPart
=
0
;
idxPart
<
loader
.
getNumberOfParticles
()
;
++
idxPart
)
{
loader
.
fillParticle
(
&
particlePosition
,
&
physicalValue
);
tree
.
insert
(
particlePosition
,
idxPart
);
tree
.
insert
(
particlePosition
);
}
}
template
<
class
OctreeClass
>
void
loadTree
(
OctreeClass
&
tree
,
FRandomLoader
&
loader
)
{
FPoint
particlePosition
;
// insertion
for
(
int
idxPart
=
0
;
idxPart
<
loader
.
getNumberOfParticles
()
;
++
idxPart
)
{
loader
.
fillParticle
(
&
particlePosition
);
tree
.
insert
(
particlePosition
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment