Commit fcda9898 authored by Praetorius, Simon's avatar Praetorius, Simon

Merge branch 'feature/make_operator_shortcuts' into 'develop'

add shortcuts zot(), fot(), and sot() for backward compatibility/similarity with old AMDiS

See merge request spraetor/dune-amdis!97
parents 9a05dcc7 b60644a3
Pipeline #1802 canceled with stage
......@@ -14,6 +14,7 @@ namespace AMDiS
namespace tag
{
struct gradtest_trial {};
struct grad_test {};
}
......@@ -33,6 +34,14 @@ namespace AMDiS
{}
};
/// Create a first-order term with derivative on trial-function
template <class Expr, class... QuadratureArgs>
auto fot(Expr&& expr, tag::grad_test, QuadratureArgs&&... args)
{
return makeOperator(tag::gradtest_trial{}, FWD(expr), FWD(args)...);
}
/** @} **/
} // end namespace AMDiS
......@@ -17,6 +17,11 @@ namespace AMDiS
{
std::size_t comp;
};
struct partial_test
{
std::size_t comp;
};
}
......@@ -36,6 +41,14 @@ namespace AMDiS
{}
};
/// Create a first-order term with derivative on trial-function
template <class Expr, class... QuadratureArgs>
auto fot(Expr&& expr, tag::partial_test t, QuadratureArgs&&... args)
{
return makeOperator(tag::partialtest_trial{t.comp}, FWD(expr), FWD(args)...);
}
/** @} **/
} // end namespace AMDiS
......@@ -17,6 +17,7 @@ namespace AMDiS
namespace tag
{
struct test_gradtrial {};
struct grad_trial {};
}
......@@ -97,6 +98,14 @@ namespace AMDiS
}
};
/// Create a first-order term with derivative on test-function
template <class Expr, class... QuadratureArgs>
auto fot(Expr&& expr, tag::grad_trial, QuadratureArgs&&... args)
{
return makeOperator(tag::test_gradtrial{}, FWD(expr), FWD(args)...);
}
/** @} **/
} // end namespace AMDiS
......@@ -20,6 +20,11 @@ namespace AMDiS
{
std::size_t comp;
};
struct partial_trial
{
std::size_t comp;
};
}
......@@ -104,6 +109,14 @@ namespace AMDiS
std::size_t comp_;
};
/// Create a first-order term with derivative on trial-function
template <class Expr, class... QuadratureArgs>
auto fot(Expr&& expr, tag::partial_trial t, QuadratureArgs&&... args)
{
return makeOperator(tag::test_partialtrial{t.comp}, FWD(expr), FWD(args)...);
}
/** @} **/
} // end namespace AMDiS
......@@ -230,6 +230,13 @@ namespace AMDiS
}
};
/// Create a second-order term
template <class Expr, class... QuadratureArgs>
auto sot(Expr&& expr, QuadratureArgs&&... args)
{
return makeOperator(tag::gradtest_gradtrial{}, FWD(expr), FWD(args)...);
}
/** @} **/
} // end namespace AMDiS
......@@ -114,6 +114,14 @@ namespace AMDiS
std::size_t compTrial_;
};
/// Create a second-order term of partial derivatives
template <class Expr, class... QuadratureArgs>
auto sot_ij(Expr&& expr, std::size_t comp_test, std::size_t comp_trial, QuadratureArgs&&... args)
{
return makeOperator(tag::partialtest_partialtrial{comp_test, comp_trial}, FWD(expr), FWD(args)...);
}
/** @} **/
} // end namespace AMDiS
......@@ -51,7 +51,39 @@ namespace AMDiS
getElementMatrixStandard(context, quad, rowNode, colNode, elementMatrix);
}
template <class Context, class Node, class ElementVector>
void getElementVector(Context const& context,
Node const& node,
ElementVector& elementVector)
{
static_assert(Node::isLeaf, "Operator can be applied to Leaf-Nodes only");
auto const& quad = this->getQuadratureRule(context.type(), node);
auto const& localFE = node.finiteElement();
std::size_t size = localFE.size();
NodeQuadCache<Node> cache(localFE.localBasis());
auto const& shapeValuesCache = cache.evaluateFunctionAtQP(context,quad);
for (std::size_t iq = 0; iq < quad.size(); ++iq) {
// Position of the current quadrature point in the reference element
decltype(auto) local = context.local(quad[iq].position());
// The multiplicative factor in the integral transformation formula
const auto factor = Super::coefficient(local) * context.integrationElement(quad[iq].position())
* quad[iq].weight();
auto const& shapeValues = shapeValuesCache[iq];
for (std::size_t i = 0; i < size; ++i) {
const auto local_i = node.localIndex(i);
elementVector[local_i] += factor * shapeValues[i];
}
}
}
protected:
template <class Context, class QuadratureRule, class RowNode, class ColNode, class ElementMatrix>
void getElementMatrixStandard(Context const& context,
QuadratureRule const& quad,
......@@ -138,6 +170,14 @@ namespace AMDiS
}
};
/// Create a zero-order term
template <class Expr, class... QuadratureArgs>
auto zot(Expr&& expr, QuadratureArgs&&... args)
{
return makeOperator(tag::test_trial{}, FWD(expr), FWD(args)...);
}
/** @} **/
} // end namespace AMDiS
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