CAID-GUI

Tutorial

Objective: At the end of this tutorial you will understand how to run, manipulate and mesh 2D objects.

You can launch CAID by running

caid

or giving the wkl session file

caid mysession.wkl

or adding the xml geometry file

caid mygeometry.xml

or giving the pfl field file, only for visualization

caid myfield.pfl

CAID is based on some fundomental windows that are:

workgroup

Inspector

Viewer

fields

spaces

When you run CAID without any argument, you can only see the workgroup window. You can then create a new workgroup, or open a stored one.

  • Run CAID without any argument (Fig caid_fig0).
_images/workgroup.png
  • Create a new Project (Workgroup) (Fig caid_fig1).

    In the File menu, click on new

_images/workgroup_new.png
  • An empty geometry object is already created. When you select a geometry object, you can see the corresponding list of buttons, in the Inspector (Fig caid_fig2)
_images/Inspector_geometry_actions.png
  • CAID offers some predefined geometries (Fig caid_fig3)
_images/Inspector_new_geometry.png
  • Click on the circle button. This will create a circle domain, using one single patch. You need to specify its radius (Fig caid_fig4)
_images/circle.png
  • When you select a patch object, you can see the corresponding list of buttons, in the Inspector (Fig caid_fig5)
_images/Inspector_patch_actions.png
  • By expanding a patch object, you can see its attributs in the Inspector (Fig caid_fig6). These attributs are:
    • rational if the patch is a rational B-spline (NURBS)
    • dimension this is the parametric dimension: 1 for curves, 2 for surfaces and 3 for volumes
    • shape number of control points in each parametric direction
    • degree B-splines degrees for each direction
    • points Control Points
    • weights weights of the NURBS. Default value for B-splines patchs is an array of ones
    • orientation this is the orientation of the outward normal vectors to the patch boundary, given for each face of the parametric domain.
    • faces The faces of a patch are viewed as geometries objects. This is very useful when we want to specify boundary conditions. A face object can be extracted by clicking on the right mouse button.
_images/Inspector_patch_expand.png

Another useful description of the circle, is given with 5 patchs. Select any geometry object to get access to geometries actions. Then click on the new button, and the circle5mp button. (Fig caid_fig7)

_images/Inspector_new_circle5mp.png

The corresponding object is shown in (Fig caid_fig8_)

_images/circle5mp.png

By expanding the geometry object, you get access to the external faces (Fig caid_fig8a_)

_images/Inspector_circle5mp_externalfaces.png

the internal faces (Fig caid_fig8b_)

_images/inspector_circle5mp_internalfaces.png

and the inter-patch connectivity (Fig caid_fig8c_)

_images/Inspector_circle5mp_connectivity.png

When selecting a patch from a geometry* object, it is automatically highlighted. You can also specify a color for each patch, by selecting it and right click.(Fig caid_fig9)

_images/circle5mp_color_patch.png

After selecting colors, we get the final plot (Fig caid_fig10)

_images/circle5mp_fig.png
  • Editing a Control Point, can be done by selecting a patch, right-click on edit control points. A new window is opend that lists all control points and their weights. When selecting a control point, it is automatically highlighted in the Viewer (Fig caid_fig11a)
_images/circle5mp_editpoints.png

Select the control point of interest, and right-click on edit. A new window opens, and you need to set the new values for the selected control point (Fig caid_fig11b)

_images/Edit_Point.png

After modification, the new geometry is (Fig caid_fig11c)

_images/circle5mp_modified.png

Inspector

Geometry Actions

Patch Actions

Viewer

Can be done by moving the mouse wheel or its equivalent on laptop.

To change the camera position maintain the left button pressed while mouving the mouse.

Shows the Viewer Preferences window which is a notebook containing the following pages

1- The grid page (Fig. viewer_actions_fig_preferences_grid).

_images/viewer_actions_preferences_grid.png

Viewer Preferences: The grid page.

2- The colors page (Fig. viewer_actions_fig_preferences_colors).

_images/viewer_actions_preferences_colors.png

Viewer Preferences: The colors page.

3- The viewer page (Fig. viewer_actions_fig_preferences_viewer).

_images/viewer_actions_preferences_viewer.png

Viewer Preferences: The viewer page.

Todo

a rajouter

  • 2D view

    Puts and fixes the camera perpendicular to the 2D plan

  • 3D view

    Unclampes the camera in order to have a 3D view

  • Show Grid

    Shows the grid (needs a 2D view)

  • Hide Grid

    Hides the grid

  • Grid as Points

    Sets the grid as points rather than lines

  • Grid as Lines

    Sets the grid as lines

  • Clear Markers

    Clears the Marker list points

  • Clear Selected Points

    Clears the Selected list points

  • Fixed Markers

    Uses the nearest point to the grid when selecting it from the viewer

  • Floating Markers

    Uses a Floating Marker (the opposite of Fixed Markers action)

  • Add Marker

    Edits and adds a new Marker

  • Import Markers

    Imports Markers from a given file

  • Export Markers

    Exports and save the Markers points list

  • Print

    Prints the current viewer

  • Preferences

    See Viewer Preferences for more details.

Fields

CAID can be used to visualize B-spline/NURBS objects defined on a given geometry. These objects can be the result of you own B-spline based solver, or using pigasus. For the moment, only the pfl extension, which is based on XML format, is allowed. The solution must be defined as a couple (geometry,geometry_v) where geometry describes the mapping and geometry_v the B-spline/NURBS objects. In igakit and CAID, this is known as a field.

An example of use is the following:

caid U.pfl

You can find in caid/models/fields some examples of such fields. In figures (Fig. inspector_field_poisson_circle Fig. inspector_field_neumann_quart_circle) we show some of them:

_images/inspector_field_poisson_circle.png

Plot of the numerical solution of the Poisson equation on a circle.

_images/inspector_field_neumann_quart_circle.png

Plot of the numerical solution of the Laplace equation, with Neumann boundaries conditions, on a quart-circle.

Note

The actual version in CAID uses a Python loop to evaluate and draw all Bezier surfaces. A new version based on OpenGL shaders has been implemented, which uses GPU capabilities. This is a work under progress.

  • Zoom In/Out

Can be done by moving the mouse wheel or its equivalent on laptop.

  • Camera Position

To change the camera position maintain the left button pressed while mouving the mouse.

Here are given the list keybord shortcuts.

  • m or M

    Access the Viewer Preferences window

  • ESC

    Closes the Viewer window

Shows the Viewer Preferences window which is a notebook containing the following pages

1- The Menu page (Fig. inspector_field_viewer_fig_preferences_grid).

_images/inspector_field_viewer_preferences_menu.png

Viewer Preferences: The Menu page.

2- The colors page (Fig. inspector_field_viewer_fig_preferences_colors).

_images/inspector_field_viewer_preferences_colormap.png

Viewer Preferences: The colormap page.

3- The viewer page (Fig. inspector_field_viewer_fig_preferences_viewer).

_images/inspector_field_viewer_preferences_colorbar.png

Viewer Preferences: The colorbar page.

Vectorial Spaces

In this section, we show how to construct a discrete vectorial space for a given geometry after scpecifying the boundary conditions.

1- In the geometry inspector window, select the geometry that you want to use.

2- Press the Mouse Right-button and click on Set Boundary Conditions

3- Navigate through the geometry in the inspector, and choose a boundary condition for each face of interest. This is done by a Right-button mouse click as shown in (Fig. inspector_spaces_set_boundary_condition).

_images/inspector_spaces_set_boundary_condition.png

Choose a boundary condition on a specific face

4- If you want to have Dirichlet boundary condition on the whole domain, skip the last point and right-click on the geometry. Then choose Dirichlet Boundary Condition (see Fig. inspector_spaces_set_boundary_condition_final)

5- When you have finished the last remaining step is to save these bondary conditions as shown in (Fig. inspector_spaces_set_boundary_condition_final)

_images/inspector_spaces_set_boundary_condition_final.png

Choose Dirichlet boundary conditions or save them.

6- Finally, create the vectorial space with a right-click on the geometry as shown in (Fig. inspector_spaces_create_vectorial_space)

_images/inspector_spaces_create_vectorial_space.png

Create the vectorial space after specifying the boundary conditions.

A new window appears which contains a space inspector (see Fig. inspector_spaces). As you can see, you have access to the geometry and a new object: the connectivity.

_images/inspector_spaces.png

The space inspector.

The connectivity is defined using two arrays:

  • ID which maps the global id of a basis function with its position in the discrete matrix.
  • LM given a patch and an element tuple (or an element global index), this array maps the local index of the basis function to its id in ID

The user can export these arrays by a right-click on the connectivity and then press Export, as shown in (Fig. inspector_spaces_connectivity_export)

_images/inspector_spaces_connectivity_export.png

Export the connectivity (ID and LM arrays) of the current vectorial space.

PyShell

CAID offers the possibility of using command lines and manipulating geometries directly from a Python Shell. First select the current workgroup and then click on Start Command Line in the Tools menu (or press keyboard shortcut F9). The Python Shell window appears, which look likes (Fig. )

_images/pyshell.png

The internal Python Shell.

In the current example, in order to access to the list of geometries of the current workgroup, type:

>>> geometries
[<geometry.geometry object at 0x497cad0>, <geometry.geometry object at 0x497ca90>, <geometry.geometry object at 0x497ce50>]

While the workgroup can be accessed via:

>>> workgroup

You can for example, run a poisson solver on a given geometry:

>>> geo = geometries[2]
>>> f = lambda x,y:[x*y]
>>> run_poisson(geo, AllDirichlet=True, f=f)

as shown in figure (Fig. pyshell_run_poisson)

_images/pyshell_run_poisson.png

Runing the Poisson solver on a given geometry.

Note

This work is under progress. In the future, the user will be able to access the geometry by given its name. We will add other solvers too.

When a workgroup is selected in the workgroup tree inspector, it can be accessed using:

>>> wk = workgroup

A geometry object can be accessed by given its id using:

>>> geo = geometries[0]

Todo

access geometry by name

You can make your own plugin visible inside PyShell by adding it:

gvim $CAID_SRC/PyShell.py

and adding your import and modifying the setVisibleVariables function:

>>> def setVisibleVariables(self):
>>>     wk = self.parent.tree.currentWorkGroup
>>>     # ... workgroup
>>>     __main__.__dict__["workgroup"]  = wk
>>>     # ... geometry elements
>>>      __main__.__dict__["geometries"]  = wk.list_geo

Macro Recording

Macro Recording is a capability that allows users to record almost in action (both geometry and patch actions) and generate the equivalent Python script (macro).

To activate the Macro Recording capability, press Macro Recording in Tools menu, or press F4 if the current workgroup is selected in the workgroup inspector tree.

Once you finish, press again on F4 or Stop Macro Recording in Tools menu. A Python Editor window will open with the recorded actions. You can modify the file and save it somewhere.

You can open and edit your macro by pressing Python Editor in Tools menu or F3 if the current workgroup is selected in the workgroup inspector tree.

In order to run the generated macro press on the execute button in the Python Editor.

Python Editor

CAID embeeds a Python Editor. You can interact with CAID via the editor by executing your own Python commands.

To open the Python Editor, press Python Editor in Tools menu, or press F3 if the current workgroup is selected in the workgroup inspector tree.

You can open and edit your macro or script by pressing Python Editor in Tools menu or F3 if the current workgroup is selected in the workgroup inspector tree.

In order to execute your macro or script press on the execute button in the Python Editor.

The following example shows how to create a nem geometry object and add it into the workgroup. Let us consider the following python script:

import numpy as np
from igakit.nurbs import NURBS
from igakit.cad_geometry import *
from geometry import geometry

def make_crv():
    C = [[ 6.0, 0.0, 6.0],
         [-5.5, 0.5, 5.5],
         [-5.0, 1.0,-5.0],
         [ 4.5, 1.5,-4.5],
         [ 4.0, 2.0, 4.0],
         [-3.5, 2.5, 3.5],
         [-3.0, 3.0,-3.0],
         [ 2.5, 3.5,-2.5],
         [ 2.0, 4.0, 2.0],
         [-1.5, 4.5, 1.5],
         [-1.0, 5.0,-1.0],
         [ 0.5, 5.5,-0.5],
         [ 0.0, 6.0, 0.0],]
    U = [0, 0, 0, 0,
         .1, .2, .3, .4, .5, .6, .7, .8, .9,
         1, 1, 1, 1,]
    nrb = NURBS([U], C)
    return nrb

nrb = make_crv()
cad_nrb = cad_nurbs(nrb.knots, nrb.points)
geo = cad_geometry()
geo.append(cad_nrb)

wk = workgroup
wk.add_geometry(geometry(geo))
wk.Refresh(inspector=True)

save and store it somewhere, and then run CAID. Press F3 and open it in the Python Editor.

_images/pythoneditor_example_curve.png

The Python Editor using the previous script.

press execute, you’ll see the following curve in the viewer

_images/pythoneditor_example_curve_viewer.png

The result of the previous script.

Macros and Plugins