Skip to content
Snippets Groups Projects
Commit f0675c08 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Refactoring exact nonlinear diffusion.

parent f5d084b5
No related branches found
No related tags found
No related merge requests found
......@@ -20,71 +20,97 @@
#include <functions/tnlDomain.h>
template< typename OperatorQ, int Dimensions >
template< typename Nonlinearity, int Dimensions >
class tnlExactNonlinearDiffusion
{};
template< typename OperatorQ >
class tnlExactNonlinearDiffusion< OperatorQ, 1 > : public tnlDomain< 1, SpaceDomain >
template< typename Nonlinearity >
class tnlExactNonlinearDiffusion< Nonlinearity, 1 >
: public tnlDomain< 1, SpaceDomain >
{
public:
enum { Dimensions = 1 };
static tnlString getType();
#ifdef HAVE_NOT_CXX11
template< typename Function, typename Vertex, typename Real >
#else
template< typename Function, typename Vertex, typename Real = typename Vertex::RealType >
#endif
static tnlString getType()
{
return "tnlExactNonlinearDiffusion< " + Nonlinearity::getType() + ", 1 >";
};
void setNonlinearity( const Nonlinearity& nonlinearity )
{
this->nonlinearity = nonlinearity;
}
template< typename Function >
__cuda_callable__
Real operator()( const Function& function,
const Vertex& v,
const Real& time = 0.0 ) const;
const Real& time = 0.0 ) const
{
const Real u_x = function.template getPartialDerivative< 1, 0, 0 >( v, time );
const Real u_xx = function.template getPartialDerivative< 2, 0, 0 >( v, time );
const Real g = nonlinearity( function, v, time )
const Real g_x = nonlinearity::template getPartialDerivative< Function, 1, 0, 0 >( function, v, time );
return u_xx - u_x * g_x / g;
}
protected:
Nonlinearity nonlinearity;
};
template< typename OperatorQ >
class tnlExactNonlinearDiffusion< OperatorQ, 2 > : public tnlDomain< 2, SpaceDomain >
template< typename Nonlinearity >
class tnlExactNonlinearDiffusion< Nonlinearity, 2 >
: public tnlDomain< 2, SpaceDomain >
{
public:
enum { Dimensions = 2 };
static tnlString getType();
static tnlString getType()
{
return "tnlExactNonlinearDiffusion< " + Nonlinearity::getType() + ", 2 >";
};
#ifdef HAVE_NOT_CXX11
template< typename Function, typename Vertex, typename Real >
#else
template< typename Function, typename Vertex, typename Real = typename Vertex::RealType >
#endif
void setNonlinearity( const Nonlinearity& nonlinearity )
{
this->nonlinearity = nonlinearity;
}
template< typename Function >
__cuda_callable__
Real operator()( const Function& function,
const Vertex& v,
const VertexType& v,
const Real& time = 0.0 ) const;
protected:
Nonlinearity nonlinearity;
};
template< typename OperatorQ >
class tnlExactNonlinearDiffusion< OperatorQ, 3 > : public tnlDomain< 3, SpaceDomain >
template< typename Nonlinearity >
class tnlExactNonlinearDiffusion< Nonlinearity, 3 >
: public tnlDomain< 3, SpaceDomain >
{
public:
enum { Dimensions = 3 };
static tnlString getType();
#ifdef HAVE_NOT_CXX11
template< typename Function, typename Vertex, typename Real >
#else
template< typename Function, typename Vertex, typename Real = typename Vertex::RealType >
#endif
static tnlString getType()
{
return "tnlExactNonlinearDiffusion< " + Nonlinearity::getType() + ", 3 >";
}
void setNonlinearity( const Nonlinearity& nonlinearity )
{
this->nonlinearity = nonlinearity;
}
template< typename Function >
__cuda_callable__
Real operator()( const Function& function,
const Vertex& v,
const VertexType& v,
const Real& time = 0.0 ) const;
protected:
Nonlinearity nonlinearity;
};
#include "tnlExactNonlinearDiffusion_impl.h"
......
......@@ -18,73 +18,73 @@
#ifndef TNLEXACTNONLINEARDIFFUSION_IMPL_H_
#define TNLEXACTNONLINEARDIFFUSION_IMPL_H_
template< typename OperatorQ >
template< typename Nonlinearity >
tnlString
tnlExactNonlinearDiffusion< OperatorQ, 1 >::
tnlExactNonlinearDiffusion< Nonlinearity, 1 >::
getType()
{
return "tnlExactNonlinearDiffusion< " + OperatorQ::getType() + ", 1 >";
return "tnlExactNonlinearDiffusion< " + Nonlinearity::getType() + ", 1 >";
}
template< typename OperatorQ >
template< typename Nonlinearity >
template< typename Function, typename Vertex, typename Real >
__cuda_callable__
Real
tnlExactNonlinearDiffusion< OperatorQ, 1 >::
tnlExactNonlinearDiffusion< Nonlinearity, 1 >::
operator()( const Function& function,
const Vertex& v,
const Real& time ) const
{
return function.template getPartialDerivative< 2, 0, 0 >( v, time ) - function.template getPartialDerivative< 1, 0, 0 >( v, time )
* OperatorQ::template getPartialDerivative<1, 0, 0>(function, v, time ) / OperatorQ::template getPartialDerivative<0, 0, 0>(function, v, time );
* Nonlinearity::template getPartialDerivative< Function, 1, 0, 0>(function, v, time ) / Nonlinearity( function, v, time );
}
template< typename OperatorQ >
template< typename Nonlinearity >
tnlString
tnlExactNonlinearDiffusion< OperatorQ, 2 >::
tnlExactNonlinearDiffusion< Nonlinearity, 2 >::
getType()
{
return "tnlExactNonlinearDiffusion< " + OperatorQ::getType() + ", 2 >";
return "tnlExactNonlinearDiffusion< " + Nonlinearity::getType() + ", 2 >";
}
template< typename OperatorQ >
template< typename Nonlinearity >
template< typename Function, typename Vertex, typename Real >
__cuda_callable__
Real
tnlExactNonlinearDiffusion< OperatorQ, 2 >::
tnlExactNonlinearDiffusion< Nonlinearity, 2 >::
operator()( const Function& function,
const Vertex& v,
const Real& time ) const
{
return function.template getPartialDerivative< 2, 0, 0 >( v, time ) + function.template getPartialDerivative< 0, 2, 0 >( v, time )
-( OperatorQ::template getPartialDerivative<1, 0, 0> (function, v, time) * function.template getPartialDerivative< 1, 0, 0 >( v, time )
+ OperatorQ::template getPartialDerivative<0, 1, 0> (function, v, time) * function.template getPartialDerivative< 0, 1, 0 >( v, time ) )
/ OperatorQ::template getPartialDerivative<0, 0, 0> (function, v, time);
-( Nonlinearity::template getPartialDerivative<1, 0, 0> (function, v, time) * function.template getPartialDerivative< 1, 0, 0 >( v, time )
+ Nonlinearity::template getPartialDerivative<0, 1, 0> (function, v, time) * function.template getPartialDerivative< 0, 1, 0 >( v, time ) )
/ Nonlinearity::template getPartialDerivative<0, 0, 0> (function, v, time);
}
template< typename OperatorQ >
template< typename Nonlinearity >
tnlString
tnlExactNonlinearDiffusion< OperatorQ, 3 >::
tnlExactNonlinearDiffusion< Nonlinearity, 3 >::
getType()
{
return "tnlExactNonlinearDiffusion< " + OperatorQ::getType() + ", 3 >";
return "tnlExactNonlinearDiffusion< " + Nonlinearity::getType() + ", 3 >";
}
template< typename OperatorQ >
template< typename Nonlinearity >
template< typename Function, typename Vertex, typename Real >
__cuda_callable__
Real
tnlExactNonlinearDiffusion< OperatorQ, 3 >::
tnlExactNonlinearDiffusion< Nonlinearity, 3 >::
operator()( const Function& function,
const Vertex& v,
const Real& time ) const
{
return function.template getPartialDerivative< 2, 0, 0 >( v, time ) + function.template getPartialDerivative< 0, 2, 0 >( v, time )
+ function.template getPartialDerivative< 0, 0, 2 >( v, time )
-( OperatorQ::template getPartialDerivative<1, 0, 0> (function, v, time) * function.template getPartialDerivative< 1, 0, 0 >( v, time )
+ OperatorQ::template getPartialDerivative<0, 1, 0> (function, v, time) * function.template getPartialDerivative< 0, 1, 0 >( v, time )
+ OperatorQ::template getPartialDerivative<0, 0, 1> (function, v, time) * function.template getPartialDerivative< 0, 0, 1 >( v, time ) )
/ OperatorQ::template getPartialDerivative<0, 0, 0> (function, v, time);
-( Nonlinearity::template getPartialDerivative<1, 0, 0> (function, v, time) * function.template getPartialDerivative< 1, 0, 0 >( v, time )
+ Nonlinearity::template getPartialDerivative<0, 1, 0> (function, v, time) * function.template getPartialDerivative< 0, 1, 0 >( v, time )
+ Nonlinearity::template getPartialDerivative<0, 0, 1> (function, v, time) * function.template getPartialDerivative< 0, 0, 1 >( v, time ) )
/ Nonlinearity::template getPartialDerivative<0, 0, 0> (function, v, time);
}
#endif /* TNLEXACTNONLINEARDIFFUSION_IMPL_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment