Commit e1508154 authored by alkaemper's avatar alkaemper
Browse files

initial try to correct functionspace

parent 352ef292
Pipeline #12730 failed with stage
in 20 minutes and 39 seconds
......@@ -953,6 +953,7 @@ namespace Dune
static_assert(std::is_same<Operation, PlusOperation>::value ||
std::is_same<Operation, MinusOperation>::value,
"Unsupported operation");
static_assert(std::is_same<typename LeftDecay::FunctionSpaceType, typename RightDecay::FunctionSpaceType>::value, "Trying to combine models with incompatible function spaces");
static_assert(std::is_same<AllArgs<LeftDecay>, AllArgs<RightDecay> >::value,
"Trying to combine models with incompatible function spaces");
using ThisType = BinaryModelExpression;
......
......@@ -11,6 +11,25 @@ namespace Dune {
namespace ACFem::PDEModel {
namespace Impl {
template<class FunctionSpace>
struct DivergenceFunctionSpaceHelper
{
using FunctionSpaceType = typename FunctionSpace::ScalarFunctionSpaceType;
};
template<typename DomainFieldImp, typename RangeFieldImp, int n, int m1, int m2>
struct DivergenceFunctionSpaceHelper<Fem::MatrixFunctionSpace<DomainFieldImp, RangeFieldImp, n, m1, m2> >
{
using FunctionSpaceType = Fem::FunctionSpace<DomainFieldImp, RangeFieldImp, n, m1>;
};
}
template<class Function>
using DivergenceFunctionSpace = typename Impl::DivergenceFunctionSpaceHelper<std::decay_t<typename Function::FunctionSpaceType> >::FunctionSpaceType;
/**@addtogroup PDE-Models
* @{
*/
......@@ -50,7 +69,7 @@ namespace Dune {
*/
template<class GridFunction>
class WeakDivergenceLoadModel
: public ModelBase<typename std::decay_t<GridFunction>::FunctionSpaceType::ScalarFunctionSpaceType>
: public ModelBase<DivergenceFunctionSpace<GridFunction> >
, public Expressions::SelfExpression<WeakDivergenceLoadModel<GridFunction> >
, public MPL::UniqueTags<ConditionalType<ExpressionTraits<GridFunction>::isVolatile, VolatileExpression, void>,
ConditionalType<IsConstantExprArg<GridFunction>::value, ConstantExpression, void>,
......@@ -60,7 +79,7 @@ namespace Dune {
"GridFunction must provide a local function");
using ThisType = WeakDivergenceLoadModel;
using BaseType = ModelBase<typename std::decay_t<GridFunction>::FunctionSpaceType::ScalarFunctionSpaceType>;
using BaseType = ModelBase<DivergenceFunctionSpace<GridFunction> >;
using GridFunctionDecay = std::decay_t<GridFunction>;
using LocalFunctionType = Fem::ConstLocalFunction<GridFunctionDecay>;
public:
......@@ -109,7 +128,7 @@ namespace Dune {
template<class Quadrature>
JacobianRangeType flux(const QuadraturePoint<Quadrature> &x) const
{
const DomainType dataValue = localFunction_.evaluate(x);
const auto dataValue = localFunction_.evaluate(x);
JacobianRangeType flux = 0;
// value * IdentityMatrix
......@@ -128,8 +147,21 @@ namespace Dune {
const auto divergenceData = localFunction_.jacobian(x);
RangeType result = 0;
for (int i = 0; i < dimWorld; ++i) {
result[0] += divergenceData[i][i];
if constexpr(dimRange == 1)
{
for (int i = 0; i < dimWorld; ++i) {
result[0] += divergenceData[i][i];
}
}
else
{
for (int j = 0; j < dimRange; ++j)
{
for (int i = 0; i < dimWorld; ++i) {
result[j] += divergenceData[j][i][i];
}
}
}
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment