-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cherry-pick-0901f441' into 'releases/2.9'
Merge branch 'feature/raviart-thomas-pyramid-and-prism' into 'releases/2.9'' See merge request core/dune-localfunctions!232
- Loading branch information
Showing
14 changed files
with
747 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- | ||
// vi: set et ts=4 sw=2 sts=2: | ||
// SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root | ||
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception | ||
#ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_HH | ||
#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_HH | ||
|
||
#include <dune/geometry/type.hh> | ||
|
||
#include "../common/localfiniteelementtraits.hh" | ||
#include "raviartthomas0prism/raviartthomas0prismlocalbasis.hh" | ||
#include "raviartthomas0prism/raviartthomas0prismlocalcoefficients.hh" | ||
#include "raviartthomas0prism/raviartthomas0prismlocalinterpolation.hh" | ||
|
||
namespace Dune | ||
{ | ||
/** | ||
* \brief First order Raviart-Thomas shape functions on prisms. | ||
* | ||
* \ingroup RaviartThomas | ||
* | ||
* \tparam D Type to represent the field in the domain. | ||
* \tparam R Type to represent the field in the range. | ||
*/ | ||
template<class D, class R> | ||
class RT0PrismLocalFiniteElement | ||
{ | ||
|
||
public: | ||
typedef LocalFiniteElementTraits< | ||
RT0PrismLocalBasis<D,R>, | ||
RT0PrismLocalCoefficients, | ||
RT0PrismLocalInterpolation<RT0PrismLocalBasis<D,R> > > Traits; | ||
|
||
|
||
//! \brief Standard constructor | ||
RT0PrismLocalFiniteElement () | ||
{} | ||
|
||
/** | ||
* \brief Make set number s, where 0 <= s < 32 | ||
* | ||
* \param s Face orientation indicator | ||
*/ | ||
RT0PrismLocalFiniteElement (int s) : | ||
basis(s), | ||
interpolation(s) | ||
{} | ||
|
||
const typename Traits::LocalBasisType& localBasis () const | ||
{ | ||
return basis; | ||
} | ||
|
||
const typename Traits::LocalCoefficientsType& localCoefficients () const | ||
{ | ||
return coefficients; | ||
} | ||
|
||
const typename Traits::LocalInterpolationType& localInterpolation () const | ||
{ | ||
return interpolation; | ||
} | ||
|
||
/** \brief Number of shape functions in this finite element */ | ||
unsigned int size () const | ||
{ | ||
return basis.size(); | ||
} | ||
|
||
static constexpr GeometryType type () | ||
{ | ||
return GeometryTypes::prism; | ||
} | ||
|
||
private: | ||
RT0PrismLocalBasis<D,R> basis; | ||
RT0PrismLocalCoefficients coefficients; | ||
RT0PrismLocalInterpolation<RT0PrismLocalBasis<D,R> > interpolation; | ||
}; | ||
} | ||
#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_HH |
8 changes: 8 additions & 0 deletions
8
dune/localfunctions/raviartthomas/raviartthomas0prism/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root | ||
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception | ||
|
||
install(FILES | ||
raviartthomas0prismlocalbasis.hh | ||
raviartthomas0prismlocalcoefficients.hh | ||
raviartthomas0prismlocalinterpolation.hh | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/localfunctions/raviartthomas/raviartthomas0prism) |
129 changes: 129 additions & 0 deletions
129
dune/localfunctions/raviartthomas/raviartthomas0prism/raviartthomas0prismlocalbasis.hh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- | ||
// vi: set et ts=4 sw=2 sts=2: | ||
// SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root | ||
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception | ||
#ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALBASIS_HH | ||
#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALBASIS_HH | ||
|
||
#include <numeric> | ||
#include <vector> | ||
|
||
#include <dune/common/fmatrix.hh> | ||
|
||
#include "../../common/localbasis.hh" | ||
|
||
namespace Dune | ||
{ | ||
/** | ||
* \ingroup LocalBasisImplementation | ||
* \brief First order Raviart-Thomas shape functions on the reference prism. | ||
* | ||
* \tparam D Type to represent the field in the domain. | ||
* \tparam R Type to represent the field in the range. | ||
* | ||
* \nosubgrouping | ||
*/ | ||
template<class D, class R> | ||
class RT0PrismLocalBasis | ||
{ | ||
|
||
public: | ||
typedef LocalBasisTraits<D,3,Dune::FieldVector<D,3>,R,3,Dune::FieldVector<R,3>, | ||
Dune::FieldMatrix<R,3,3> > Traits; | ||
|
||
/** | ||
* \brief Make set number s, where 0 <= s < 32 | ||
* | ||
* \param s Edge orientation indicator | ||
*/ | ||
RT0PrismLocalBasis (std::bitset<5> s = 0) | ||
{ | ||
for (size_t i=0; i<size(); i++) | ||
sign[i] = s[i] ? -1.0 : 1.0; | ||
} | ||
|
||
//! \brief number of shape functions | ||
unsigned int size () const | ||
{ | ||
return 5; | ||
} | ||
|
||
/** | ||
* \brief Evaluate all shape functions | ||
* | ||
* \param in Position | ||
* \param out return value | ||
*/ | ||
inline void evaluateFunction (const typename Traits::DomainType& in, | ||
std::vector<typename Traits::RangeType>& out) const | ||
{ | ||
out.resize(5); | ||
|
||
out[0] = { in[0], -1.0 + in[1], 0.0}; | ||
|
||
out[1] = { -1.0 + in[0], in[1], 0.0}; | ||
|
||
out[2] = { in[0], in[1], 0.0}; | ||
|
||
out[3] = { 0.0, 0.0, -2.0 + 2.0*in[2]}; | ||
|
||
out[4] = { 0.0, 0.0, 2.0*in[2]}; | ||
|
||
for (std::size_t i=0; i<out.size(); i++) | ||
out[i] *= sign[i]; | ||
|
||
} | ||
|
||
/** | ||
* \brief Evaluate Jacobian of all shape functions | ||
* | ||
* \param in Position | ||
* \param out return value | ||
*/ | ||
inline void evaluateJacobian (const typename Traits::DomainType& in, | ||
std::vector<typename Traits::JacobianType>& out) const | ||
{ | ||
out.resize(5); | ||
|
||
for(int i=0; i<size(); i++) | ||
for(int j=0; j<3; j++) | ||
out[i][j] = {0.0, 0.0, 0.0}; | ||
|
||
out[0][0][0] = sign[0]; | ||
out[0][1][1] = sign[0]; | ||
|
||
out[1][0][0] = sign[1]; | ||
out[1][1][1] = sign[1]; | ||
|
||
out[2][0][0] = sign[2]; | ||
out[2][1][1] = sign[2]; | ||
|
||
out[3][2][2] = sign[3]*(2.0); | ||
|
||
out[4][2][2] = sign[4]*(2.0); | ||
} | ||
|
||
//! \brief Evaluate partial derivatives of all shape functions | ||
void partial (const std::array<unsigned int, 3>& order, | ||
const typename Traits::DomainType& in, // position | ||
std::vector<typename Traits::RangeType>& out) const // return value | ||
{ | ||
auto totalOrder = std::accumulate(order.begin(), order.end(), 0); | ||
if (totalOrder == 0) { | ||
evaluateFunction(in, out); | ||
} else { | ||
DUNE_THROW(NotImplemented, "Desired derivative order is not implemented"); | ||
} | ||
} | ||
|
||
//! \brief Polynomial order of the shape functions | ||
unsigned int order () const | ||
{ | ||
return 1; | ||
} | ||
|
||
private: | ||
std::array<R,5> sign; | ||
}; | ||
} | ||
#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALBASIS_HH |
50 changes: 50 additions & 0 deletions
50
.../localfunctions/raviartthomas/raviartthomas0prism/raviartthomas0prismlocalcoefficients.hh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- | ||
// vi: set et ts=4 sw=2 sts=2: | ||
// SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root | ||
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception | ||
#ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALCOEFFICIENTS_HH | ||
#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALCOEFFICIENTS_HH | ||
|
||
#include <cstddef> | ||
#include <vector> | ||
|
||
#include "../../common/localkey.hh" | ||
|
||
namespace Dune | ||
{ | ||
|
||
/** | ||
* \ingroup LocalLayoutImplementation | ||
* \brief Layout map for Raviart-Thomas-1 elements on prisms. | ||
* | ||
* \nosubgrouping | ||
* \implements Dune::LocalCoefficientsVirtualImp | ||
*/ | ||
class RT0PrismLocalCoefficients | ||
{ | ||
|
||
public: | ||
//! \brief Standard constructor | ||
RT0PrismLocalCoefficients () : li(size()) | ||
{ | ||
for(int i=0; i< size(); i++) | ||
li[i] = LocalKey(i,1,0); | ||
} | ||
|
||
//! \brief number of coefficients | ||
std::size_t size () const | ||
{ | ||
return 5; | ||
} | ||
|
||
//! \brief get i'th index | ||
const LocalKey& localKey (std::size_t i) const | ||
{ | ||
return li[i]; | ||
} | ||
|
||
private: | ||
std::vector<LocalKey> li; | ||
}; | ||
} | ||
#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALCOEFFICIENTS_HH |
91 changes: 91 additions & 0 deletions
91
...localfunctions/raviartthomas/raviartthomas0prism/raviartthomas0prismlocalinterpolation.hh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- | ||
// vi: set et ts=4 sw=2 sts=2: | ||
// SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root | ||
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception | ||
#ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALINTERPOLATION_HH | ||
#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALINTERPOLATION_HH | ||
|
||
#include <vector> | ||
|
||
#include <dune/localfunctions/common/localinterpolation.hh> | ||
|
||
namespace Dune | ||
{ | ||
/** | ||
* \ingroup LocalInterpolationImplementation | ||
* \brief First order Raviart-Thomas shape functions on the reference prism. | ||
* | ||
* \tparam LB corresponding LocalBasis giving traits | ||
* | ||
* \nosubgrouping | ||
*/ | ||
template<class LB> | ||
class RT0PrismLocalInterpolation | ||
{ | ||
|
||
public: | ||
|
||
/** | ||
* \brief Make set number s, where 0 <= s < 32 | ||
* | ||
* \param s Face orientation indicator | ||
*/ | ||
RT0PrismLocalInterpolation (std::bitset<5> s = 0) | ||
{ | ||
typedef typename LB::Traits::RangeFieldType Scalar; | ||
|
||
for (size_t i=0; i<5; i++) | ||
sign[i] = (s[i]) ? -1.0 : 1.0; | ||
|
||
Scalar r = 1/std::sqrt(2); | ||
|
||
n[0] = { 0.0, -1.0, 0.0}; | ||
n[1] = {-1.0, 0.0, 0.0}; | ||
n[2] = { r, r, 0.0}; | ||
n[3] = { 0.0, 0.0, -1.0}; | ||
n[4] = { 0.0, 0.0, 1.0}; | ||
|
||
c[0] = 1.0; | ||
c[1] = 1.0; | ||
c[2] = std::sqrt(2); | ||
c[3] = 1/2.0; | ||
c[4] = 1/2.0; | ||
|
||
m[0] = { 0.5, 0.0, 0.5}; | ||
m[1] = { 0.0, 0.5, 0.5}; | ||
m[2] = { 0.5, 0.5, 0.5}; | ||
m[3] = { 1/3.0, 1/3.0, 0.0}; | ||
m[4] = { 1/3.0, 1/3.0, 1.0}; | ||
} | ||
|
||
/** | ||
* \brief Interpolate a given function with shape functions | ||
* | ||
* \tparam F Function type for function which should be interpolated | ||
* \tparam C Coefficient type | ||
* \param ff function which should be interpolated | ||
* \param out return value, vector of coefficients | ||
*/ | ||
template<class F, class C> | ||
void interpolate (const F& ff, std::vector<C>& out) const | ||
{ | ||
auto&& f = Impl::makeFunctionWithCallOperator<typename LB::Traits::DomainType>(ff); | ||
|
||
out.resize(5); | ||
for(int i=0; i<5; i++) | ||
out[i] = f(m[i]).dot(n[i]) * c[i] * sign[i]; | ||
} | ||
|
||
private: | ||
// Facet orientations | ||
std::array<typename LB::Traits::RangeFieldType, 5> sign; | ||
// Facet area | ||
std::array<typename LB::Traits::RangeFieldType, 5> c; | ||
|
||
// Facet normals | ||
std::array<typename LB::Traits::DomainType, 5> n; | ||
// Facet midpoints | ||
std::array<typename LB::Traits::DomainType, 5> m; | ||
}; | ||
} | ||
#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALINTERPOLATION_HH |
Oops, something went wrong.