hemisphere with hollow bottom

Dear all,
I am a beginner here. I hope you guys can help me with my problem.

I wanted to create a hemisphere geometry with a hollow bottom. And i write .geo file like this:

algebraic3d

solid main=sphere(0,0,0;1)
and plane(0,0,0;0,0,-1);
tlo main;

However i obtained a hemisphere with a closed bottom. Really appreciate it if you guys can help me this one.

Hi suzarina3,

is this part of the documentation (6.1.2 Surface PDEs — NGS-Py 6.2.2302 documentation) what you are after?

Best wishes,
Henry

Hi, it would also be easy to do this using the opencascade wrapper in ngsolve:

from netgen.occ import *

face = Sphere((0,0,0),1).faces[0]
face *= HalfSpace((0,0,0),(0,0,1))

geo = OCCGeometry(face)

is it the same? as I am using Netgen 5.0.0. As I load the geometry, it said that

Load CSG geometry file C:/Users/suzarina sukri/Desktop/TESTING .GEO FILE/hemisphere_try.geo
read unidentified token 101 (as char: “e”) string = from
read unidentified token 101 (as char: “e”) string = netgen
read unidentified token 100 (as char: “d”) string = netgen

Thanks a millions for replying my questions.

Hi, my advice would be to go for the current Netgen which comes with NGSolve. My guess from you output is that your version is from before the introduction of the python interface.

Christophers code is a python script rather than a geo file.

Dear,

I downloaded the new version for python and NG Solver. Is the step the same as the old version?

Before this, I just load .geo file (I modified only this file to get the basic geometry)

Load geometry–>sphere.geo(example)

So now I need to load python file or what? So sorry sir for asking too many simple question. I really hope you can reply to my questions. :slight_smile:

Thank you so much sir for your kind reply. I really need them. :cry:

This depends a bit on what you’re after.

Put the above code into a my_script.py file, and add a last line Draw(geo). By running a terminal in the location where you saved the script, you can run this with the gui by calling netgen my_script.py, and then continue in the gui.

Alternatively, you can do everything in the python script (see Interactive NGSolve Tutorial — NGS-Py 6.2.2302 documentation) and then run python3 my_script.py.

Dear sir.

Thanks a million for your reply. :slight_smile:
I seriously appreciated it.

Dear sir,
When i load the python file, i get the error as this:

AttributeError: ‘netgen.libngpy._csg.Solid’ object has no attribute ‘faces’
Finished executing C:/Users/suzarina sukri/Downloads/hemisphere.py

what does it means? sorry to bother you again sir

Hi,
it appears that there is some mix-up between the occ wrapper code and the i-tutorial code, which use the netgen.csg Shpere object. Could you please post you example file?

Do you mean this code?

from netgen.occ import *

face = Sphere((0,0,0),1).faces[0]
face *= HalfSpace((0,0,0),(0,0,1))

geo = OCCGeometry(face)
Draw(geo)

Thank you so much sir

sorry sir, this is the code

from netgen.occ import *
from netgen.csg import *
from ngsolve.webgui import Draw

face = Sphere((0,0,0),1).faces[0]
face *= HalfSpace((0,0,0),(0,0,1))

geo = OCCGeometry(face)
Draw(geo)

You need to remove the line ‘from netgen.csg import *’. Both the netgen occ and csg submodules have a Sphere object, so the occ one you want is overwritten by the csg one when you do the second import.

I take it you are now using a jupyter-notebook? Otherwise you also need to remove the line ‘from ngsolve.webgui import Draw’ to visualise in the old netgen gui.

dear sir,

actually I am not using Jupiter-notebook. I am using python (py-charm). I downloaded only the following software to run the Netgen. Am I wrong?

Install Python 3.7 if you do not already have it. Make sure to download one of the “x86-64” installers, and select the option “Add Python 3.7 to PATH” during the installation. Direct link to the installer
Install the Microsoft Visual Studio 2017 Redistributables.
Download the Netgen/NGSolve msi - installer of the latest release
Reboot your system after the installation and proceed to Getting started with Netgen/NGSolve

Do I need to install Jupiter-notebook? Can you please tell me what should I install? I am so sorry to bother you sir. I know this question might be the basic question, but I would really appreciate it, if you can give me the guideline. Thanks a million sir

Dear sir,

A millions of thank you for you. I finally got the geometry that I want based on your suggestions.
Thank you so much for your kind help. I pray everything in your life went ease and smooth.
Thank you so much sir. :slight_smile: :slight_smile: :slight_smile: