do you mean something like

Code: Select all

`group_values_dict = {"positive":(0,4)} # (default_value, marked_value)`

I tested the above but it did not work for me.

I used the following code to export the mesh form FC:

Code: Select all

```
fileString = 'mesh_simplest_air_in_box_model.xdmf'
group_values_dict = {"positive":(0,4)} # (default_value, marked_value)
# import Fenics main module
import fenics as fe
# import FreeCAD modules
import FreeCADGui
import FreeCAD
# import Fenics interface classes
from feminout.importFenicsMesh import writeFenicsXDMF
from femsolver.fenics.fenics_tools import CellExpressionXDMF, FacetFunctionXDMF
"""
set Python executable to an appropriate value to maintain instant functionality
during the make process
"""
import sys
sys.executable = '/usr/bin/python'
# Select mesh in active document and export it to a temporary file
sel = FreeCADGui.Selection.getSelection()
if len(sel) == 1 and FreeCAD.ActiveDocument is not None:
sel = sel[0]
# writeFenicsXDMF.write_fenics_mesh_xdmf(sel, "mesh.xdmf")
writeFenicsXDMF.write_fenics_mesh_xdmf(sel, fileString, group_values_dict)
```

Furthermore, I do get different values when selecting directly with e.g. ds(2) and ff.ds["positive"] for integration (both should address the same boundary)

**EDIT**:but only ds(2) is correct\EDIT. This is shown in the minimal example below (it should be ready for copy paste and run

**EDIT**please look for

*"assemble( (u) *ff.ds["positive"])"*\EDIT):

Code: Select all

```
from dolfin import *
import sys
sys.path.append(r'/usr/lib/freecad/lib')
import FreeCAD as FC
from feminout.importFenicsMesh import writeFenicsXDMF
from femsolver.fenics.fenics_tools import CellExpressionXDMF, FacetFunctionXDMF
# # Setting up and solving the model
length = 10.0 # x-dir in m, distance between plates
depth = 10.0 # y-dir in m, depth of capacitor plate
height = 10.0 # z-dir in m, heigth of capacitor plate
V1 = -3. # V, potential on first plate
V2 = 10. # V, potential on second plate
e1 = Expression(str(V1), degree=1)
e2 = Expression(str(V2), degree=1)
boundarydict = {"negative":{"type":"Dirichlet", "value":e1}, #, "marked":1
"positive":{"type":"Dirichlet", "value":e2}, #, "marked":2
}
ff = FacetFunctionXDMF("mesh_simplest_air_in_box_model.xdmf", boundarydict)
#ff = FacetFunctionXDMF("mesh_simplest_air_in_box_model.orig.xdmf", boundarydict)
mesh = ff.mesh
# Initialize mesh function for boundary domains
boundaries = FacetFunction("size_t", mesh)
boundaries.set_all(0)
# Create classes for defining parts of the boundaries and the interior
# of the domain
class Left(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], 0.0)
class Right(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], length)
# Initialize sub-domain instances
left = Left()
right = Right()
# Initialize mesh function for interior domains
domains = CellFunction("size_t", mesh)
domains.set_all(0)
# Initialize mesh function for boundary domains
left.mark(boundaries, 1)
right.mark(boundaries, 2)
# Initialize mesh function for interior domains
domains = CellFunction("size_t", mesh)
# Define input data
a0 = Constant(1.0) # epsilon_r
g_L = 0
g_R = 0
f = 0
# Define function space and basis functions
V = FunctionSpace(mesh, "Lagrange", 1) # V = FunctionSpace(mesh, "CG", 2)
u = TrialFunction(V)
v = TestFunction(V)
bcs = ff.getDirichletBCs(V)
# Define new measures associated with the interior domains and
# exterior boundaries
dx = Measure('dx', domain=mesh, subdomain_data=domains)
ds = Measure('ds', domain=mesh, subdomain_data=boundaries)
# Define variational form
F = (inner(a0*grad(u), grad(v))*dx(0)
- g_L*v*ds(1) - g_R*v*ds(2)
- f*v*dx(0) )
# Separate left and right hand sides of equation
a, L = lhs(F), rhs(F)
# Solve problem
u = Function(V)
solve(a == L, u, bcs)
print("\n\n#############################################")
print("The following two values should be identical")
print("assemble( (u) *ds(2)) = "+str(assemble( u*ds(2))))
print("assemble( (u) *ff.ds['positive']) = "+str(assemble( (u) *ff.ds["positive"])))
```

Do you have any idea whats going wrong??

Thanks in advance,

BR,

HoWil