NGSolve / ngsolve

Netgen/NGSolve is a high performance multiphysics finite element software. It is widely used to analyze models from solid mechanics, fluid dynamics and electromagnetics. Due to its flexible Python interface new physical equations and solution algorithms can be implemented easily.

Home Page:https://ngsolve.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installing using conda

frlacf opened this issue · comments

Hi,

I'm new here, I think you guys made an amazing job with your FEM framework. I'm trying to install ngsolve on miniconda here is what I do:

conda create --name ngsolve --channel ngsolve

conda activate ngsolve

conda install ngsolve

Everything seems to be fine so far, ngsolve is installed, but then when I run

from ngsolve import *

I get:

importing NGSolve-6.2.2006-48-gdd7aae9c5

Caught exception:
arg(): could not convert default argument into a Python object (type not registered yet?). Compile in debug mode for more information.
Traceback (most recent call last):
File "", line 1, in
File "/home/francisl/miniconda3/envs/ngsolve/lib/python3.7/site-packages/ngsolve/init.py", line 13, in
from .ngslib import version, ngstd, bla, la, fem, comp, solve
ImportError: cannot import name 'fem' from 'ngsolve' (/home/francisl/miniconda3/envs/ngsolve/lib/python3.7/site-packages/ngsolve/ngslib.so)

Also, I have a question concerning the code. Is it possible to export/import solution in any format ? We use an FEM code for very niche applications but would like to use NGsolve's adaptive mesh refinement capabilities, so if there was a way to import results from a generic format (cgns, paraview, Ensight, Tecplot) and then use that in NGsolve to adapt the mesh, that would be cool. Anyway, great work guys.

Francis

Hi Francis,

I think your issue is similar to the one mentioned here:
https://ngsolve.org/forum/ngspy-forum/972-conda-installers-available?start=18
The problem there is that conda installs an incompatible netgen package from conda-forge.
For now I recommend using the ngsolve-nightly package. I will hereby close this issue, reopen if you still have troubles.

NGSolve currently can export .vtk-Files ( https://ngsolve.org/showcases/ngsolve/2-vtk-output ) and import .cgns:

def LoadCGNS( fname ):                                                                                                                                                                                   
    from ngsolve import Mesh, H1, L2, GridFunction
    from ngsolve.fem import NODE_TYPE
    from netgen.meshing import ReadCGNSFile

    ngmesh, *rest = ReadCGNSFile(fname)

    mesh = Mesh(ngmesh)
    functions = []

    for name, values, node_type in zip(*rest):
        if node_type == NODE_TYPE.VERTEX:
            fes = H1(mesh, order=1)
        elif node_type == NODE_TYPE.CELL:
            fes = L2(mesh, order=0)
        else:
            print("Unknown node type for function", name, node_type)
            continue
        u = GridFunction(fes, name)

        assert len(u.vec) == len(values)

        u.vec.FV().NumPy()[:] = values.NumPy()
    
        functions.append(u)
    return mesh,functions

mesh, solutions = LoadCGNS( "the_cgns_file.cgns" )

import ngsolve
for s in solutions:
    ngsolve.Draw(s)

Best,
Matthias