Skip to content
Snippets Groups Projects
Commit a57d471d authored by Timon Habenicht's avatar Timon Habenicht
Browse files

adds Kernel and KernelFactory to VirtualFluids

parent c79e7b06
No related branches found
No related tags found
No related merge requests found
#ifndef KERNEL_H
#define KERNEL_H
//#include "VirtualFluids_GPU\GPU\GPU_Interface.h"
#include <DataTypes.h>
#include <cuda_runtime.h>
#include <helper_functions.h>
#include <helper_cuda.h>
class Parameter;
class Kernel
{
public:
virtual void run()=0;
virtual bool checkParameter() = 0;
protected:
};
#endif
\ No newline at end of file
#include "KernelFactory.h"
#include "Advection\Compressible\CumulantOne\CumulantOneCompSP27.h"
#include "Advection\Compressible\CumulantAA2016\CumulantAA2016CompSP27.h"
#include "Advection\Compressible\CumulantAll4\CumulantAll4CompSP27.h"
std::shared_ptr<KernelFactory> KernelFactory::getNewInstance(std::shared_ptr<Parameter> para)
{
return std::shared_ptr<KernelFactory>(new KernelFactory(para));
}
std::vector<std::shared_ptr<Kernel>> KernelFactory::makeKernels(int maxLevel, std::string kernelName)
{
kernels.resize(0);
for (int i = 0; i <= maxLevel; i++)
{
kernels.push_back(makeKernel(kernelName, i));
}
return kernels;
}
void KernelFactory::setKernelAtLevel(std::vector<std::shared_ptr<Kernel>> kernels, int i, std::string kernelName)
{
kernels.at(i) = makeKernel(kernelName, i);
}
std::shared_ptr<Kernel> KernelFactory::makeKernel(std::string kernelName, int level)
{
if (kernelName == "CumulantOneCompSP27")
return CumulantOneCompSP27::getNewInstance(para, level);
if (kernelName == "CumulantAA2016CompSP27")
return CumulantAA2016CompSP27::getNewInstance(para, level);
if (kernelName == "CumulantAll4CompSP27")
return CumulantAA2016CompSP27::getNewInstance(para, level);
}
KernelFactory::KernelFactory(std::shared_ptr<Parameter> para)
{
this->para = para;
kernels.resize(0);
}
\ No newline at end of file
#ifndef KERNEL_FACTORY_H
#define KERNEL_FACTORY_H
#include <memory>
#include <vector>
#include <iostream>
class Kernel;
class Parameter;
class KernelFactory
{
public:
static std::shared_ptr< KernelFactory> getNewInstance(std::shared_ptr<Parameter> para);
std::vector< std::shared_ptr< Kernel>> makeKernels(int maxLevel, std::string kernelName);
void setKernelAtLevel(std::vector< std::shared_ptr<Kernel>> kernels, int i, std::string kernelName);
private:
std::shared_ptr< Kernel> makeKernel(std::string kernelName, int level);
KernelFactory(std::shared_ptr<Parameter> para);
KernelFactory();
std::vector< std::shared_ptr< Kernel>> kernels;
std::shared_ptr< Parameter> para;
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment