Code Monkey home page Code Monkey logo

fenicstools's People

Contributors

aslakbergersen avatar francesco-ballarin avatar mikaem avatar mirok avatar sma-user avatar testmikaem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fenicstools's Issues

Error after installing

Hi Mikaem,

After installing fenicstools, I tried importing it and I got the error below. Could you tell me what is wrong ?

Best,
Fabien

In [1]: import fenicstools
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:7: UserWarning: Probe/Probes/StatisticsProbe/StatisticsProbes not installed
warnings.warn("Probe/Probes/StatisticsProbe/StatisticsProbes not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:12: UserWarning: StructuredGrid/ChannelGrid not installed
warnings.warn("StructuredGrid/ChannelGrid not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:17: UserWarning: weighted_gradient_matrix/compiled_gradient_module not installed
warnings.warn("weighted_gradient_matrix/compiled_gradient_module not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:22: UserWarning: getMemoryUsage/SetMatrixValue not installed
warnings.warn("getMemoryUsage/SetMatrixValue not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:27: UserWarning: gauss_divergence/divergence_matrix not installed
warnings.warn("gauss_divergence/divergence_matrix not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:32: UserWarning: interpolate_nonmatching_mesh/interpolate_nonmatching_mesh_any not installed
warnings.warn("interpolate_nonmatching_mesh/interpolate_nonmatching_mesh_any not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:37: UserWarning: DofMapPlotter not installed
warnings.warn("DofMapPlotter not installed") # Probably missing dependency

UserWarnings after "python setup.py install"

Hi Mikaem,

I cloned fenicstools and installed it with the command "python setup.py install". Importing your library I have the following error :

/Users/anonymous/anaconda2/envs/pyfenics/lib/python3.6/site-packages/fenicstools/init.py:7: UserWarning: Probe/Probes/StatisticsProbe/StatisticsProbes not installed
warnings.warn("Probe/Probes/StatisticsProbe/StatisticsProbes not installed")
/Users/anonymous/anaconda2/envs/pyfenics/lib/python3.6/site-packages/fenicstools/init.py:12: UserWarning: StructuredGrid/ChannelGrid not installed
warnings.warn("StructuredGrid/ChannelGrid not installed")
/Users/anonymous/anaconda2/envs/pyfenics/lib/python3.6/site-packages/fenicstools/init.py:42: UserWarning: ClementInterpolation not installed
warnings.warn("ClementInterpolation not installed")
/Users/anonymous/anaconda2/envs/pyfenics/lib/python3.6/site-packages/fenicstools/init.py:47: UserWarning: Lagrangian particles not installed
warnings.warn("Lagrangian particles not installed")

Do you have any idea how to solve this issue ?

update to 2016.2?

Since the current of version of fences is 2016.2, will you update this package so that it works with 2016.2 fenics?

By the way, does interpolate in fenicstools works for DG function? For example, I want to interpolate a DG finite element function from coarse mesh to fine mesh (say it is a uniform refinement from the coarse the mesh).

import on error

HI,

cloned the repo and installed. I get this error on importing fenicstools:

python -c "import fenicstools"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/vagrant/home/.installdir/lib/python2.7/site-packages/fenicstools/__init__.py", line 8, in <module>
    from DofMapPlotter import DofMapPlotter
ImportError: cannot import name DofMapPlotter

I cannot understant why python complains about DofMapPlotter, which is in the path.

Davide

import / compile error

Hi,

I cloned the repository and installed using pip , but when I import the module it fails. The last part of the log file is:

/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx:2962:21: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
   "in method '" name"', argument "argn" of type '"type"'"
                     ^
/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx:2962:39: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
   "in method '" name"', argument "argn" of type '"type"'"
                                       ^
/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx:2964:3: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
   "invalid null reference "SWIG_ArgFail_Fmt(type, name, argn)
   ^
/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx:2966:3: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
   "in method '"name"', output value of type '"type"'"
   ^
/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx:2966:20: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
   "in method '"name"', output value of type '"type"'"
                    ^
/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx: In function ‘void dolfin::compute_weight(dolfin::Function&)’:
/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx:3221:13: error: ‘ArrayView’ does not name a type
       const ArrayView<const dolfin::la_index> dofs
             ^
/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx:3225:38: error: ‘dofs’ was not declared in this scope
       dg_vector.add_local(ws.data(), dofs.size(), dofs.data());    
                                      ^
make[2]: *** [CMakeFiles/_dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71.dir/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71PYTHON_wrap.cxx.o] Error 1
make[2]: Leaving directory `/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71'
make[1]: *** [CMakeFiles/_dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71.dir/all] Error 2
make[1]: Leaving directory `/tmp/tmphsuB2L2015-4-14-18-53_instant_8c4236ba92321f6a18183df80a56b8930f30b708/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71'
make: *** [all] Error 2

When importing in Python I get:

Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/home/david/.instant/error/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/compile.log'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/fenicstools/__init__.py", line 3, in <module>
    from WeightedGradient import weighted_gradient_matrix, compiled_gradient_module
  File "/usr/local/lib/python2.7/dist-packages/fenicstools/WeightedGradient.py", line 10, in <module>
    compiled_gradient_module = compile_extension_module(code=gradient_code)
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 64, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/compilemodule.py", line 458, in compile_extension_module
    **instant_kwargs)
  File "/usr/lib/python2.7/dist-packages/instant/build.py", line 563, in build_module
    recompile(modulename, module_path, new_compilation_checksum, build_system)
  File "/usr/lib/python2.7/dist-packages/instant/build.py", line 165, in recompile
    instant_error(msg % (cmd, compile_log_filename_dest))
  File "/usr/lib/python2.7/dist-packages/instant/output.py", line 85, in instant_error
    raise RuntimeError(text)
RuntimeError: In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/home/david/.instant/error/dolfin_compile_code_0ccf5c1b9e7646eaa482022bf965d1f2ae835d71/compile.log'

Regards

AttributeError: Can't pickle local object 'RandomCircle.__init__.<locals>.<lambda>'

Hi,
I have trouble running the LagrangianParicles demo. I setup FEniCS 2018.1 using Docker via

fenicsproject create fenicstools
fenicsproject start fenicstools

and then installed fenicstools within the Docker using

sudo python3 setup.py install

When I run

python3 demo/demo_LagrangianParticles.py

I get

/usr/local/lib/python3.5/dist-packages/fenicstools/__init__.py:7: UserWarning: Probe/Probes/StatisticsProbe/StatisticsProbes not installed
  warnings.warn("Probe/Probes/StatisticsProbe/StatisticsProbes not installed")
/usr/local/lib/python3.5/dist-packages/fenicstools/__init__.py:12: UserWarning: StructuredGrid/ChannelGrid not installed
  warnings.warn("StructuredGrid/ChannelGrid not installed")
/usr/local/lib/python3.5/dist-packages/fenicstools/__init__.py:17: UserWarning: weighted_gradient_matrix/compiled_gradient_module not installed
  warnings.warn("weighted_gradient_matrix/compiled_gradient_module not installed")
/usr/local/lib/python3.5/dist-packages/fenicstools/__init__.py:22: UserWarning: getMemoryUsage/SetMatrixValue not installed
  warnings.warn("getMemoryUsage/SetMatrixValue not installed")
/usr/local/lib/python3.5/dist-packages/fenicstools/__init__.py:27: UserWarning: gauss_divergence/divergence_matrix not installed
  warnings.warn("gauss_divergence/divergence_matrix not installed")
/usr/local/lib/python3.5/dist-packages/fenicstools/__init__.py:32: UserWarning: interpolate_nonmatching_mesh/interpolate_nonmatching_mesh_any not installed
  warnings.warn("interpolate_nonmatching_mesh/interpolate_nonmatching_mesh_any not installed")
/usr/local/lib/python3.5/dist-packages/fenicstools/__init__.py:37: UserWarning: DofMapPlotter not installed
  warnings.warn("DofMapPlotter not installed") # Probably missing dependency
Traceback (most recent call last):
  File "demo/demo_LagrangianParticles.py", line 10, in <module>
    particle_positions = RandomCircle([0.5, 0.75], 0.15).generate([100, 100])
  File "/usr/local/lib/python3.5/dist-packages/fenicstools/LagrangianParticles.py", line 474, in generate
    points_inside = comm.bcast(points_inside, root=0)
  File "mpi4py/MPI/Comm.pyx", line 1257, in mpi4py.MPI.Comm.bcast
  File "mpi4py/MPI/msgpickle.pxi", line 629, in mpi4py.MPI.PyMPI_bcast
  File "mpi4py/MPI/msgpickle.pxi", line 104, in mpi4py.MPI.Pickle.dump
  File "mpi4py/MPI/msgpickle.pxi", line 91, in mpi4py.MPI.Pickle.cdumps
AttributeError: Can't pickle local object 'RandomCircle.__init__.<locals>.<lambda>'
Aborted (core dumped)

How can I fix this?

testing fails

testing is failing with:

export INSTANT_CACHE_DIR=$(pwd)/instant
export DIJITSO_CACHE_DIR=$(pwd)/instant

pushd tests
python -b -m pytest -vs

is it a known bug ?

=================================== FAILURES ===================================
_________________________ test_Probes_functionspace_3D _________________________

V3 = FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 479), FiniteElement('Lagrange', tetrahedron, 1))
dirpath = '<...>/tests/tmp/'

    def test_Probes_functionspace_3D(V3, dirpath):
        u0 = interpolate(Expression('x[0]', degree=1), V3)
        x = array([[0.5, 0.5, 0.5], [0.4, 0.4, 0.4], [0.3, 0.3, 0.3]])
    
        p = Probes(x.flatten(), V3)
    
        # Probe twice
        p(u0)
        p(u0)
    
        # Check both snapshots
        p0 = p.array(N=0)
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0] - 0.5, 7) == 0
            assert round(p0[1] - 0.4, 7) == 0
            assert round(p0[2] - 0.3, 7) == 0
        p0 = p.array(N=1)
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0] - 0.5, 7) == 0
            assert round(p0[1] - 0.4, 7) == 0
            assert round(p0[2] - 0.3, 7) == 0
    
        p0 = p.array(filename=dirpath+'dump')
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0, 0] - 0.5, 7) == 0
            assert round(p0[1, 1] - 0.4, 7) == 0
            assert round(p0[2, 1] - 0.3, 7) == 0
    
            f = open(dirpath+'dump_all.probes', 'r')
>           p1 = load(f)

test_Probes.py:62: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../_t_env/lib/python3.6/site-packages/numpy/lib/npyio.py:391: in load
    magic = fid.read(N)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <encodings.utf_8.IncrementalDecoder object at 0x7fa6bb2b2b38>
input = b'\x80\x02cnumpy.core.multiarray\n_reconstruct\nq\x00cnumpy\nndarray\nq\x01K\x00\x85q\x02c_codecs\nencode\nq\x03X\x01\...c2\x9b\xc2\x99\xc2\x99\xc2\x99\xc2\x99\xc2\x99\xc3\x99?433333\xc3\x93?433333\xc3\x93?q\x11h\x05\x86q\x12Rq\x13tq\x14b.'
final = False

    def decode(self, input, final=False):
        # decode input (taking the buffer into account)
        data = self.buffer + input
>       (result, consumed) = self._buffer_decode(data, self.errors, final)
E       UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

../../_t_env/lib/python3.6/codecs.py:321: UnicodeDecodeError
______________________ test_Probes_vectorfunctionspace_2D ______________________

VF2 = FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 471), VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2))
dirpath = '<...>/tests/tmp/'

    def test_Probes_vectorfunctionspace_2D(VF2, dirpath):
        u0 = interpolate(Expression(('x[0]', 'x[1]'), degree=1), VF2)
        x = array([[0.5, 0.5], [0.4, 0.4], [0.3, 0.3]])
    
        p = Probes(x.flatten(), VF2)
    
        # Probe twice
        p(u0)
        p(u0)
    
        # Check both snapshots
        p0 = p.array(N=0)
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0, 0] - 0.5, 7) == 0
            assert round(p0[1, 1] - 0.4, 7) == 0
            assert round(p0[2, 1] - 0.3, 7) == 0
        p0 = p.array(N=1)
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0, 0] - 0.5, 7) == 0
            assert round(p0[1, 0] - 0.4, 7) == 0
            assert round(p0[2, 1] - 0.3, 7) == 0
    
        p0 = p.array(filename=dirpath+'dumpvector2D')
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0, 0, 0] - 0.5, 7) == 0
            assert round(p0[1, 1, 1] - 0.4, 7) == 0
            assert round(p0[2, 0, 1] - 0.3, 7) == 0
    
            f = open(dirpath+'dumpvector2D_all.probes', 'r')
>           p1 = load(f)

test_Probes.py:97: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../_t_env/lib/python3.6/site-packages/numpy/lib/npyio.py:391: in load
    magic = fid.read(N)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <encodings.utf_8.IncrementalDecoder object at 0x7fa6b91bda58>
input = b'\x80\x02cnumpy.core.multiarray\n_reconstruct\nq\x00cnumpy\nndarray\nq\x01K\x00\x85q\x02c_codecs\nencode\nq\x03X\x01\...\xc2\x99\xc2\x99\xc3\x99?;33333\xc3\x93?;33333\xc3\x93?:33333\xc3\x93?:33333\xc3\x93?q\x11h\x05\x86q\x12Rq\x13tq\x14b.'
final = False

    def decode(self, input, final=False):
        # decode input (taking the buffer into account)
        data = self.buffer + input
>       (result, consumed) = self._buffer_decode(data, self.errors, final)
E       UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

../../_t_env/lib/python3.6/codecs.py:321: UnicodeDecodeError
______________________ test_Probes_vectorfunctionspace_3D ______________________

VF3 = FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 479), VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3))
dirpath = '<...>/tests/tmp/'

    def test_Probes_vectorfunctionspace_3D(VF3, dirpath):
        u0 = interpolate(Expression(('x[0]', 'x[1]', 'x[2]'), degree=1), VF3)
        x = array([[0.5, 0.5, 0.5], [0.4, 0.4, 0.4], [0.3, 0.3, 0.3]])
    
        p = Probes(x.flatten(), VF3)
        # Probe twice
        p(u0)
        p(u0)
    
        # Check both snapshots
        p0 = p.array(N=0)
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0, 0] - 0.5, 7) == 0
            assert round(p0[1, 1] - 0.4, 7) == 0
            assert round(p0[2, 2] - 0.3, 7) == 0
        p0 = p.array(N=1)
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0, 0] - 0.5, 7) == 0
            assert round(p0[1, 1] - 0.4, 7) == 0
            assert round(p0[2, 2] - 0.3, 7) == 0
    
        p0 = p.array(filename=dirpath+'dumpvector3D')
        if MPI.rank(mpi_comm_world()) == 0:
            assert round(p0[0, 0, 0] - 0.5, 7) == 0
            assert round(p0[1, 1, 0] - 0.4, 7) == 0
            assert round(p0[2, 1, 0] - 0.3, 7) == 0
    
            f = open(dirpath+'dumpvector3D_all.probes', 'r')
>           p1 = load(f)

test_Probes.py:131: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../_t_env/lib/python3.6/site-packages/numpy/lib/npyio.py:391: in load
    magic = fid.read(N)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <encodings.utf_8.IncrementalDecoder object at 0x7fa6bd91dac8>
input = b'\x80\x02cnumpy.core.multiarray\n_reconstruct\nq\x00cnumpy\nndarray\nq\x01K\x00\x85q\x02c_codecs\nencode\nq\x03X\x01\...3\xc3\x93?433333\xc3\x93?833333\xc3\x93?833333\xc3\x93?433333\xc3\x93?433333\xc3\x93?q\x11h\x05\x86q\x12Rq\x13tq\x14b.'
final = False

    def decode(self, input, final=False):
        # decode input (taking the buffer into account)
        data = self.buffer + input
>       (result, consumed) = self._buffer_decode(data, self.errors, final)
E       UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

../../_t_env/lib/python3.6/codecs.py:321: UnicodeDecodeError
==================== 3 failed, 31 passed in 266.89 seconds =====================

Help installing for 2018 version of FENICs

Hi,

I am having trouble installing fenicstools for my version of fenics. I have a conda environment with fenics installed (created with the following command):

conda create -n fenicsproject18 -c conda-forge fenics=2018

It seems in the setup.py script that the version is the 2019 version. Could you please advise on the best way to install fenicstools to work with my setup? I have tried a few ways and they all seem to give me different issues.

Repeated call to interpolate_nonmatching_mesh_any seems not to work

Hi!

The code below should produce two arrays of all 0s and two arrays of all 1s, but I get
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]

The code is
from dolfin import *
from fenicstools import interpolate_nonmatching_mesh_any
import numpy

mesh = UnitSquareMesh(2, 2)

V = FunctionSpace(mesh, "Nedelec 1st kind H(curl)", 1)

u0=Function(V)
u0.vector().set_local( u0.vector().get_local()*0.0 )
u0.vector().apply('insert')
print(u0.vector().get_local()) # Should be all 0
i0 = interpolate_nonmatching_mesh_any(u0, V)
print(i0.vector().get_local()) # Should be all 0

u1=Function(V)
u1.vector().set_local( u1.vector().get_local()*0.0+1.0 )
u1.vector().apply('insert')
print(u1.vector().get_local()) # Should be all 1
i1 = interpolate_nonmatching_mesh_any(u1, V)
print(i1.vector().get_local()) # Should be all 1

Is this a bug or am I doing something wrong?

Best Regards,
Søren

PS This function is a really nice and useful addition to fenics. Thanks for sharing it!

Simple probe fails

I have the following simple code test.py for probe:

from dolfin import *
from numpy import array
from fenicstools import *

mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, 'CG', 1)
u = interpolate(Expression("sin(x[0]*pi)*cos(x[1]*pi)"), V)

x = array([0.6, 0.5])
probe = Probe(x, V)
probe(u)

print "result = ", probe.get_probe_sub(0)

It gives the correct result "0" (almost) if I run it in series: python test.py
However, when I run it in parallel: mpirun -np 2 python test.py, it seems that the probe fails.

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** [email protected]


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to set probe.
*** Reason: Probe is not found on processor.
*** Where: This error was encountered inside Probe.cpp.
*** Process: 0


*** DOLFIN version: 2016.1.0
*** Git changeset:
*** -------------------------------------------------------------------------

Very interestingly, if I probe the array [0.5, 0.5], it does give the correct result.
Furthermore, I tried to use compute_first_entity_collision() directly in fenics,
it also fails. I think it might be some bugs in fenics. Could you please confirm
it or fix the bug? Thanks!

weighted gradient applications

Hello,

I am trying to calculate a smooth gradient for my solution to a drift diffusion problem. Although the solution looks smooth when using CG1 elements the gradient has a lot of artificial spikes when projecting i.e .

grad_u = project(grad(u))

I was wondering if your weighted gradient methods could help. Could you please refer me to some references on applications for it or what it is used for?

The image below should show the spikes I am talking about.
Thanks,
Chaffra

image

fencistools for fenics-2017.2

Hi,

I am wondering if there is a compatible version for fenics 2017.2.0? I am running on a fencis 2017.2 and current mater branch seems works for 2018.1, other version I found works for 2017.1.0 and I tried but got unexpected error when swigging: error: conversion from ‘Eigen::Map<const Eigen::Array<int, -1, 1> >’ to non-scalar type ‘const dolfin::ArrayView’ requested
= dofmap_u->cell_dofs(cell->index());

fenicstools on anaconda

Is fenicstools available on anaconda.

I tried conda install -c mikaem fenicstools but got an error:

PackageNotFoundError: Dependencies missing in current osx-64 channels: 
  - fenicstools -> fenics ==2017.1.dev
  - fenicstools -> h5py-parallel

Is there any way to install fenicstools via conda. I have fenics 2017.1.0 installed on my Mac via anaconda.

ClementInterpolation enhancements

Here are a few ways to improve the ClementInterpolation functionality:

  • Add an additional parameter, e.g. user's dx, that would allow to exclude certain cells from construction of the interpolant.
  • ClementInterpolation with $CG$ spaces could work also for quadratic order (across all dimensions). With polynomial order > 2 the interior dofs of entities (cell, facets, ...) would be set to same value and are therefore of little use. $CG_2$ could be added. It would require a different averaging operator.
  • Consider extensions to $BDM$, $RT$, $NED$ elements. Might be useful for evaluating normal/tangential fluxes

Compile error in Interpolate.py

Hi,
I find the StructuredGrid very useful, but it seems not to work with MPI.
I get a compile error in Interpolate.py and I guess this is related to the
MPI problems. I have attached the last part of the log-message.
I tried to locate the missing functions in Dolfin without any success.
I'm using Dolfin 1.6 on a Mac

Cheers,
Jan Ludvig Vinningland

/private/var/folders/qp/5q0w4mfd1z52mfb0m0gtm2d40000gn/T/tmpS2qZbk2016-4-4-21-44_instant_70590be213b550e021be6e6c3ad61e920413dcbb/dolfin_compile_code_2f8ced4bb0a01350ee171bcbdd6c2128b21301a3/dolfin_compile_code_2f8ced4bb0a01350ee171bcbdd6c2128b21301a3PYTHON_wrap.cxx:3382:15: error: no member named 'get_coordinate_dofs' in 'dolfin::Cell'
cell->get_coordinate_dofs(coordinate_dofs);
~~~~ ^
/private/var/folders/qp/5q0w4mfd1z52mfb0m0gtm2d40000gn/T/tmpS2qZbk2016-4-4-21-44_instant_70590be213b550e021be6e6c3ad61e920413dcbb/dolfin_compile_code_2f8ced4bb0a01350ee171bcbdd6c2128b21301a3/dolfin_compile_code_2f8ced4bb0a01350ee171bcbdd6c2128b21301a3PYTHON_wrap.cxx:3389:17: error: no member named 'tabulate_dof_coordinates' in 'dolfin::FiniteElement'
element.tabulate_dof_coordinates(coordinates, coordinate_dofs, cell);
~~~~~~~ ^
2 errors generated.
make[2]: *
* [CMakeFiles/_dolfin_compile_code_2f8ced4bb0a01350ee171bcbdd6c2128b21301a3.dir/dolfin_compile_code_2f8ced4bb0a01350ee171bcbdd6c2128b21301a3PYTHON_wrap.cxx.o] Error 1
make[1]: *** [CMakeFiles/_dolfin_compile_code_2f8ced4bb0a01350ee171bcbdd6c2128b21301a3.dir/all] Error 2
make: *** [all] Error 2

Multiple issues with DofMapPlotter

Hi, I just installed fenicstools hoping it would help me debug some mesh mapping issues. However, right away I am having several issues with running the DofMapPlotter. I am using 2018.1 (conda-forge).

  1. In 2018.1 mpi_comm_world() twas renamed to MPI.comm_world
  2. I see that the test code has been commented out?
  3. After fixing the mpi syntax, the demo fails on the call to dmp.plot(), error below

`dmp.plot(component=[0, n_dofmaps-2, n_dofmaps-1])
In file included from /Users/alexanderniewiarowski/fenics/fenicstools/fenicstools/dofmapplotter/cpp/.rendered.dmt.cpp:4:
In file included from /Users/alexanderniewiarowski/anaconda3/envs/fenics2018/include/python3.7m/pybind11/pybind11.h:43:
In file included from /Users/alexanderniewiarowski/anaconda3/envs/fenics2018/include/python3.7m/pybind11/attr.h:13:
In file included from /Users/alexanderniewiarowski/anaconda3/envs/fenics2018/include/python3.7m/pybind11/cast.h:13:
In file included from /Users/alexanderniewiarowski/anaconda3/envs/fenics2018/include/python3.7m/pybind11/pytypes.h:12:
/Users/alexanderniewiarowski/anaconda3/envs/fenics2018/include/python3.7m/pybind11/detail/common.h:140:10: fatal error: 'forward_list' file not found
#include <forward_list>
^~~~~~~~~~~~~~
1 error generated.
An exception has occurred, use %tb to see the full traceback.

SystemExit: error: command 'gcc' failed with exit status 1

/Users/alexanderniewiarowski/anaconda3/envs/fenics2018/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3275: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)`

Import leads to compilation and warnings


Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fenicstools
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---
/usr/local/lib/python2.7/dist-packages/fenicstools/StructuredGrid.py:14: UserWarning: Need h5py and pyvtk for StructuredGrid class to work
  warnings.warn("Need h5py and pyvtk for StructuredGrid class to work")
/usr/local/lib/python2.7/dist-packages/fenicstools/StructuredGrid.py:20: UserWarning: Errors occurred attempting to import surfc and meshgrid from scitools
  warnings.warn("Errors occurred attempting to import surfc and meshgrid from scitools")
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---

This behaviour makes it more complex for me to use your code on cross compilation platforms like modern supercomputers. Do you have any pointers on how to remove the autocompilation on import?

Permission error using when using " from fenicstools.Interpolation import interpolate_nonmatching_mesh_any "

Hi Mikaem,

I installed fenicstools with the command "python setup.py install". Importing your library I have the following error:

please can you helps me? Thanks

/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:7: UserWarning: Probe/Probes/StatisticsProbe/StatisticsProbes not installed
warnings.warn("Probe/Probes/StatisticsProbe/StatisticsProbes not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:12: UserWarning: StructuredGrid/ChannelGrid not installed
warnings.warn("StructuredGrid/ChannelGrid not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:17: UserWarning: weighted_gradient_matrix/compiled_gradient_module not installed
warnings.warn("weighted_gradient_matrix/compiled_gradient_module not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:22: UserWarning: getMemoryUsage/SetMatrixValue not installed
warnings.warn("getMemoryUsage/SetMatrixValue not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:27: UserWarning: gauss_divergence/divergence_matrix not installed
warnings.warn("gauss_divergence/divergence_matrix not installed")
/usr/local/lib/python3.6/dist-packages/fenicstools/init.py:32: UserWarning: interpolate_nonmatching_mesh/interpolate_nonmatching_mesh_any not installed
warnings.warn("interpolate_nonmatching_mesh/interpolate_nonmatching_mesh_any not installed")

Bad key text.latex.unicode in file /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle, line 112 ('text.latex.unicode : False # use "ucs" and "inputenc" LaTeX packages for handling')
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.3.4/matplotlibrc.template
or from the matplotlib source distribution

Bad key savefig.frameon in file /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle, line 423 ('savefig.frameon : True')
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.3.4/matplotlibrc.template
or from the matplotlib source distribution

Bad key pgf.debug in file /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle, line 444 ('pgf.debug : False')
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.3.4/matplotlibrc.template
or from the matplotlib source distribution

Bad key verbose.level in file /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle, line 475 ('verbose.level : silent # one of silent, helpful, debug, debug-annoying')
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.3.4/matplotlibrc.template
or from the matplotlib source distribution

Bad key verbose.fileo in file /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle, line 476 ('verbose.fileo : sys.stdout # a log filename, sys.stdout or sys.stderr')
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.3.4/matplotlibrc.template
or from the matplotlib source distribution
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The text.latex.preview rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The mathtext.fallback_to_cm rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: Support for setting the 'mathtext.fallback_to_cm' rcParam is deprecated since 3.3 and will be removed two minor releases later; use 'mathtext.fallback : 'cm' instead.
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The validate_bool_maybe_none function was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The savefig.jpeg_quality rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The keymap.all_axes rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The animation.avconv_path rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
In /home/rene-sims/.local/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The animation.avconv_args rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
Traceback (most recent call last):
File "EM_phase.py", line 6, in
from fenicstools.Interpolation import interpolate_nonmatching_mesh_any
File "/usr/local/lib/python3.6/dist-packages/fenicstools/Interpolation.py", line 8, in
compiled_fem_module = cppimport.imp('fenicstools.fem.interpolation')
File "/usr/local/lib/python3.6/dist-packages/cppimport/init.py", line 35, in imp
return imp_from_filepath(filepath, fullname)
File "/usr/local/lib/python3.6/dist-packages/cppimport/init.py", line 65, in imp_from_filepath
template_and_build(filepath, module_data)
File "/usr/local/lib/python3.6/dist-packages/cppimport/importer.py", line 17, in template_and_build
run_templating(module_data)
File "/usr/local/lib/python3.6/dist-packages/cppimport/templating.py", line 36, in run_templating
with open(rendered_src_filepath, "w", newline="") as f:
PermissionError: [Errno 13] Permission non accordée: '/usr/local/lib/python3.6/dist-packages/fenicstools/fem/.rendered.interpolation.cpp
error.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.