Skip to content
Snippets Groups Projects
Commit c672a840 authored by Robert K's avatar Robert K
Browse files

[cleanup][FVOperator] Check for cartesian and avoid volume computation.

parent ed7422da
No related branches found
No related tags found
1 merge request!48[feature][FVOperator] A specialized FV operator for finite volume.
Pipeline #59960 passed
......@@ -430,16 +430,16 @@ namespace EulerNumFlux
static void rotate(const FieldType n[dim],
const FieldType u[dim], FieldType u_rot[dim])
{
if (dim == 1)
if constexpr (dim == 1)
{
u_rot[0] = n[0] * u[0];
}
else if (dim == 2)
else if constexpr (dim == 2)
{
u_rot[0] = n[0]*u[0] + n[1]*u[1];
u_rot[1] = -n[1]*u[0] + n[0]*u[1];
}
else if (dim == 3)
else if constexpr (dim == 3)
{
FieldType d = std::sqrt(n[0]*n[0]+n[1]*n[1]);
......@@ -461,16 +461,16 @@ namespace EulerNumFlux
static void rotate_inv(const FieldType n[dim],
const FieldType u_rot[dim], FieldType u[dim])
{
if (dim == 1){
if constexpr (dim == 1){
u[0] = n[0] * u_rot[0];
}
if (dim == 2){
if constexpr (dim == 2){
u[0] = n[0]*u_rot[0] - n[1]*u_rot[1];
u[1] = n[1]*u_rot[0] + n[0]*u_rot[1];
}
if (dim == 3){
if constexpr (dim == 3){
FieldType d = std::sqrt(n[0]*n[0]+n[1]*n[1]);
if (d > 1.0e-8) {
......@@ -488,7 +488,7 @@ namespace EulerNumFlux
//assert(0); // test it, not tested up to now
}
if (dim > 3) assert(0);
if constexpr (dim > 3) assert(0);
}
};
......
......@@ -7,6 +7,7 @@
#include <dune/grid/common/geometry.hh>
#include <dune/fem/gridpart/common/capabilities.hh>
#include <dune/fem/misc/threads/threaditerator.hh>
#include <dune/grid/common/gridenums.hh>
......@@ -60,6 +61,8 @@ namespace detail
static const int dimworld = GridPartType::dimensionworld;
static const int dimRange = Model::dimRange;
typedef typename Grid::ctype ctype;
static const bool isCartesian = Fem::GridPartCapabilities::isCartesian< GridPartType >::v;
// only apply the scheme to interior elements
static const Dune :: PartitionIteratorType ptype = Dune :: InteriorBorder_Partition ;
......@@ -257,10 +260,10 @@ namespace detail
static const bool higherOrder = value ;
// cell volume
const double enVolume = geo.volume();
const ctype enVolume = geo.volume();
// 1 over cell volume
const double enVolume_1 = 1.0/enVolume;
const ctype enVolume_1 = 1.0/enVolume;
RangeType uLeft;
RangeType uRight;
......@@ -311,13 +314,12 @@ namespace detail
if( neighbor.partitionType() != InteriorEntity ||
enIndex < nbIndex )
{
const double nbVolume = neighbor.geometry().volume();
const ctype nbVolume = ( isCartesian ) ? enVolume : neighbor.geometry().volume();
const ctype nbVolume_1 = ( isCartesian ) ? enVolume_1 : 1.0/nbVolume;
// local context neighbor
LocalEvalIntersectionType right( neighbor, intersection, faceCenters_[ intersection.indexInOutside() ], localFaceCenter_, nbVolume );
// calculate (1 / neighbor volume)
const double nbVolume_1 = 1.0 / nbVolume;
// evaluate data for higher order
if constexpr ( higherOrder )
{
......
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