Skip to content
Snippets Groups Projects
Commit 11ae5151 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Force zero normal displacement on fric. boundary

parent f1bd6f2b
Branches
No related tags found
No related merge requests found
...@@ -84,9 +84,21 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject { ...@@ -84,9 +84,21 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject {
LocalVectorType &ui, int m, LocalVectorType &ui, int m,
const typename Dune::BitSetVector<block_size>::const_reference ignore) { const typename Dune::BitSetVector<block_size>::const_reference ignore) {
{ {
// TODO: Does it make any sense to ignore single spatial dimensions here? int ignore_component =
if (ignore.test(0)) block_size; // Special value that indicates nothing should be ignored
return; switch (ignore.count()) {
case 0: // Full problem
break;
case 1: // 1 Dimension is fixed
assert(
ignore[1]); // Only the second component is allowed to stay fixed
ignore_component = 1;
break;
case block_size: // Ignore the whole node
return;
default:
assert(false);
}
LocalMatrixType const *localA = NULL; LocalMatrixType const *localA = NULL;
LocalVectorType localb(problem.f[m]); LocalVectorType localb(problem.f[m]);
...@@ -105,7 +117,8 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject { ...@@ -105,7 +117,8 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject {
FunctionType f; FunctionType f;
problem.newphi.restriction(m, f); problem.newphi.restriction(m, f);
Dune::LocalNonlinearity<block_size> const phi(f); Dune::LocalNonlinearity<block_size> const phi(f);
Dune::SampleFunctional<block_size> localJ(*localA, localb, phi); Dune::SampleFunctional<block_size> localJ(*localA, localb, phi,
ignore_component);
LocalVectorType correction; LocalVectorType correction;
Dune::minimise(localJ, ui, 10, bisection); // FIXME: hardcoded value Dune::minimise(localJ, ui, 10, bisection); // FIXME: hardcoded value
......
...@@ -23,8 +23,8 @@ template <int dim> class SampleFunctional { ...@@ -23,8 +23,8 @@ template <int dim> class SampleFunctional {
typedef LocalNonlinearity<dim> NonlinearityType; typedef LocalNonlinearity<dim> NonlinearityType;
SampleFunctional(SmallMatrix const &A, SmallVector const &b, SampleFunctional(SmallMatrix const &A, SmallVector const &b,
NonlinearityType const &phi) NonlinearityType const &phi, int ignore = dim)
: A(A), b(b), phi(phi) {} : A(A), b(b), phi(phi), ignore(ignore) {}
double operator()(SmallVector const &v) const { double operator()(SmallVector const &v) const {
SmallVector y; SmallVector y;
...@@ -89,12 +89,15 @@ template <int dim> class SampleFunctional { ...@@ -89,12 +89,15 @@ template <int dim> class SampleFunctional {
SmallMatrix const &A; SmallMatrix const &A;
SmallVector const &b; SmallVector const &b;
NonlinearityType const &phi; NonlinearityType const &phi;
int const ignore;
private: private:
// Gradient of the smooth part // Gradient of the smooth part
void smoothGradient(SmallVector const &x, SmallVector &y) const { void smoothGradient(SmallVector const &x, SmallVector &y) const {
A.mv(x, y); // y = Av A.mv(x, y); // y = Av
y -= b; // y = Av - b y -= b; // y = Av - b
if (ignore != dim)
y[ignore] = 0;
} }
void upperGradient(SmallVector const &x, SmallVector &y) const { void upperGradient(SmallVector const &x, SmallVector &y) const {
...@@ -102,6 +105,8 @@ template <int dim> class SampleFunctional { ...@@ -102,6 +105,8 @@ template <int dim> class SampleFunctional {
SmallVector z; SmallVector z;
smoothGradient(x, z); smoothGradient(x, z);
y += z; y += z;
if (ignore != dim)
y[ignore] = 0;
} }
void lowerGradient(SmallVector const &x, SmallVector &y) const { void lowerGradient(SmallVector const &x, SmallVector &y) const {
...@@ -109,6 +114,8 @@ template <int dim> class SampleFunctional { ...@@ -109,6 +114,8 @@ template <int dim> class SampleFunctional {
SmallVector z; SmallVector z;
smoothGradient(x, z); smoothGradient(x, z);
y += z; y += z;
if (ignore != dim)
y[ignore] = 0;
} }
// y = (id - P)(d) where P is the projection onto the line t*x // y = (id - P)(d) where P is the projection onto the line t*x
......
...@@ -79,6 +79,7 @@ void setup_boundary(GridView const &gridView, ...@@ -79,6 +79,7 @@ void setup_boundary(GridView const &gridView,
++frictional_nodes; ++frictional_nodes;
size_t const id = myVertexMapper.map(*it); size_t const id = myVertexMapper.map(*it);
frictionalNodes[id] = true; frictionalNodes[id] = true;
ignoreNodes[id][1] = true; // Zero displacement in direction y
} }
} }
std::cout << "Number of Neumann nodes: " << neumann_nodes << std::endl; std::cout << "Number of Neumann nodes: " << neumann_nodes << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment