Commit 43688816 authored by Andreas Dedner's avatar Andreas Dedner

moved required files from original repository

parents
FROM registry.dune-project.org/staging/dune-python:unstable
MAINTAINER "Martin Nolte"
USER root
RUN apt-get update && apt-get dist-upgrade --yes --no-install-recommends
RUN apt-get install --yes --no-install-recommends \
libeigen3-dev libsuitesparse-dev \
python3-ufl
ADD install-twophasedg.sh /root/
RUN /root/install-twophasedg.sh
USER dune
WORKDIR /dune
RUN cp -r /usr/local/share/doc/dune-fempy/jupyter /dune/dune-fempy
COPY --chown=dune:dune twophaseflow.ipynb limit.py /dune/
# How to Update the Official Docker Image
To update the official Docker image on `registry.dune-project.org`,
please follow these steps:
1. Pull the Docker base image:
```
docker pull registry.dune-project.org/staging/dune-python:unstable
```
Please do not omit this step just because you already have the image. Otherwise
an outdated version of the base image might be used.
1. Actually build the Docker image:
```
docker build . --no-cache -t registry.dune-project.org/andreas.dedner/twophasedg:latest
```
Please do not omit `--no-cache` to ensure every step of the build is actually
executed.
*Note*: This will set up the Debian base system of the Docker image, which takes
quite some time.
1. Verify your build by testing the Docker image locally:
```
docker run --rm -v dune:/dune -p 127.0.0.1:8888:8888 registry.dune-project.org/andreas.dedner/twophasedg:latest
```
Use your favorite web browser, visit http://127.0.0.1:8888, enter the password
`dune`, and run the demo notebooks (depending on the jupyter version you
might be given tokenized http address to use instead).
*Note*: If you already have a volume `dune`, you will not receive the updated demo notebooks. It might be better to start with a clean volume.
1. Log into the Docker registry:
```
docker login registry.dune-project.org
```
1. Push the Docker image:
```
docker push registry.dune-project.org/andreas.dedner/twophasedg:latest
```
This step actually updates the Docker image on the server.
**Warning:** Updating the official Docker image affects all users of the
image once they pull it.
Make sure you don't push a buggy combination of the DUNE modules.
1. Log out of the Docker registry:
```
docker logout registry.dune-project.org
```
That's it.
#!/bin/bash
set -e
mkdir /tmp/dune
cd /tmp/dune
export CMAKE_FLAGS=" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=TRUE \
-DDUNE_PYTHON_INSTALL_LOCATION=system \
"
wget -qO - https://gitlab.dune-project.org/dune-fem/dune-fem/repository/archive.tar.gz?ref=feature/newton_errormeasure | tar xz
wget -qO - https://gitlab.dune-project.org/dune-fem/dune-fem-dg/repository/archive.tar.gz?ref=master | tar xz
wget -qO - https://gitlab.dune-project.org/dune-fem/dune-fempy/repository/archive.tar.gz?ref=feature/newton_errormeasure | tar xz
dunecontrol all
dunecontrol make install
cd /
rm -rf /tmp/dune
This diff is collapsed.
from __future__ import absolute_import, division, print_function, unicode_literals
import hashlib
import sys
import logging
logger = logging.getLogger(__name__)
from dune.generator import Constructor, Method
from dune.generator.generator import SimpleGenerator
from dune.generator.generator import SimpleGenerator
from dune.fem.operator import load
generator = SimpleGenerator("Operator", "Dune::FemPy")
# limiter can be ScalingLimiter or FV based limiter with FV type reconstructions for troubled cells
def createLimiter(domainSpace, rangeSpace=None, bounds = [1e-12,1.], limiter='scaling'):
if rangeSpace is None:
rangeSpace = domainSpace
domainSpaceType = domainSpace._typeName
rangeSpaceType = rangeSpace._typeName
_, domainFunctionIncludes, domainFunctionType, _, _ = domainSpace.storage
_, rangeFunctionIncludes, rangeFunctionType, _, _ = rangeSpace.storage
includes = ["dune/fem-dg/operator/limiter/limiter.hh"]
includes += domainSpace._includes + domainFunctionIncludes
includes += rangeSpace._includes + rangeFunctionIncludes
typeName = 'Dune::Fem::ScalingLimiter< ' + domainFunctionType + ', ' + rangeFunctionType + ' >'
# FV type limiter where FV based reconstructions are done
if limiter is 'fv':
typeName = 'Dune::Fem::Limiter< ' + domainFunctionType + ', ' + rangeFunctionType + ' >'
constructor = Constructor(['const '+domainSpaceType + ' &dSpace, const '+rangeSpaceType + ' &rSpace, double lower,double upper'],
['return new ' + typeName + '(dSpace,rSpace,lower,upper );'],
['"dSpace"_a', '"rSpace"_a', '"lower"_a', '"upper"_a',
'pybind11::keep_alive< 1, 2 >()', 'pybind11::keep_alive< 1, 3 >()'])
# add method activated to inspect limited cells.
activated = Method('activated', '&'+typeName+'::activated')
return load(includes, typeName, constructor, activated).Operator( domainSpace, rangeSpace, bounds[0], bounds[1] )
def createOrderRedcution(domainSpace):
domainSpaceType = domainSpace._typeName
_, domainFunctionIncludes, domainFunctionType, _, _ = domainSpace.storage
includes = ["dune/fem/operator/common/orderreduction.hh"]
includes += domainSpace._includes + domainFunctionIncludes
typeName = 'Dune::Fem::OrderReduction< ' + domainFunctionType + ' >'
constructor = Constructor(['const '+domainSpaceType + ' &dSpace'],
['return new ' + typeName + '(dSpace);'],
['"dSpace"_a','pybind11::keep_alive< 1, 2 >()'])
# add method maxRelevantOrder to get max order that is relevant per cell
# maxRelevantOrder = Method('maxRelevantOrder', '&'+typeName+'::maxRelevantOrder')
# return load(includes, typeName, constructor, maxRelevantOrder).Operator( domainSpace )
return load(includes, typeName, constructor).Operator( domainSpace )
This diff is collapsed.
#include <cstddef>
#include <dune/common/fvector.hh>
#include <dune/geometry/quadraturerules.hh>
#include <dune/fem/space/shapefunctionset/orthonormal.hh>
#include <dune/fem/quadrature/cachingquadrature.hh>
#if HAVE_DUNE_FEM_DG
#include <dune/fem-dg/operator/limiter/limiter.hh>
#endif
#include <dune/fem/misc/linesegmentsampler.hh>
template <class DiscreteFunction>
int minMax( const DiscreteFunction& solution )
{
typedef typename DiscreteFunction :: DiscreteFunctionSpaceType
DiscreteFunctionSpaceType;
typedef typename DiscreteFunctionSpaceType ::RangeType RangeType;
typedef typename DiscreteFunctionSpaceType ::GridPartType GridPartType;
const DiscreteFunctionSpaceType& space = solution.space();
const int dimRange = DiscreteFunctionSpaceType :: dimRange;
typedef Dune::Fem::CachingQuadrature< GridPartType, 0 > Quadrature;
RangeType minVal( 1e308 );
bool isNan = false;
std::vector< RangeType > values;
for( const auto& element : space )
{
Quadrature quad( element, 2*space.order( element )+3 );
auto lf = solution.localFunction( element );
const int nop = quad.nop();
values.resize( nop );
lf.evaluateQuadrature( quad, values );
for( int i=0; i<nop; ++i )
{
RangeType& val = values[ i ];
for( int d=0; d<dimRange; ++d )
{
minVal[d] = std::min( minVal[d], val[ d ] );
isNan = !(val[d]==val[d]);
}
}
}
std::cout << "Min values: p = " << minVal[0] << " s = " << minVal[1] << std::endl;
if( minVal[ 0 ] < 0 || minVal[ 1] < 0 )
return -1;
if( isNan )
return 1;
return 0;
}
template <class GF, class DT>
std::pair<std::vector<DT>, std::vector<typename GF::RangeType>>
sample(const GF &gf, DT &start, DT &end, int n)
{
Dune::Fem::LineSegmentSampler<typename GF::GridPartType> sampler(gf.gridPart(),start,end);
std::vector<DT> coords(n);
std::vector<typename GF::RangeType> values(n);
sampler(gf,values);
sampler.samplePoints(coords);
return std::make_pair(coords,values);
}
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