[Gmsh] Get sub surfaces in OpenCASCADE
chloros
chloros2 at gmx.de
Thu Aug 29 21:08:47 CEST 2019
Hello Gmsh forum,
after try and error i have found a solution. i don't know if this is
good practice so use at own risk. attached also the FreeFem script to
run a simulation.
Best regards
-------------- next part --------------
include "ffmatlib.idp"
load "UMFPACK64";
load "msh3"
load "medit"
load "gmsh"
int CUBOIDELECTRODEVOLUME = 200;
int CUBOIDELECTRODESURFACE = 100;
int TORUSSURFACE = 101;
int CYLINDERSURFACE = 102;
mesh3 Th3d = gmshload3("capacitor_opencascade_gmsh.msh");
macro Grad(u) [dx(u),dy(u),dz(u)] // EOM
fespace Vh(Th3d,P1);
Vh u,v;
fespace Qh(Th3d,P0);
Qh epsilonr = 1.0*(region==CUBOIDELECTRODEVOLUME);
problem Laplace(u,v,solver=CG) =
int3d(Th3d)( epsilonr*Grad(u)'*Grad(v) )
+on(TORUSSURFACE,u=0)
+on(CYLINDERSURFACE,u=1);
Laplace;
Vh Exn, Eyn, Ezn;
Exn = -epsilonr*dx(u);
Eyn = -epsilonr*dy(u);
Ezn = -epsilonr*dz(u);
medit("Potential",Th3d,u);
savemesh(Th3d,"capacitor_opencascade.mesh");
ffSaveVh(Th3d,Vh,"capacitor_vh.txt");
ffSaveData(u,"capacitor_u.txt");
ffSaveData3(Exn,Eyn,Ezn,"capacitor_field.txt");
-------------- next part --------------
SetFactory("OpenCASCADE");
CUBOIDELECTRODEVOLUME = 200;
CUBOIDELECTRODESURFACE = 100;
TORUSSURFACE = 101;
CYLINDERSURFACE = 102;
Mesh.CharacteristicLengthFactor = 0.3;
bwx = 1;
bwy = 1;
bwz = 0.5;
VCUBOID = newv;
Box(VCUBOID) = {-0.5*bwx, -0.5*bwy, -0.5*bwz, bwx, bwy, bwz};
SLCUBOID[] = Boundary{Volume{VCUBOID};};
//Electrodes
trlo = 0.1;
trhi = 0.25;
tz = 0.1;
VTORUS = newv;
Torus(VTORUS) = {0, 0, tz, trhi, trlo, 2*Pi};
SLTORUS[] = Boundary{Volume{VTORUS};};
cdia = 0.9;
cD = 0.05;
cgap = 0.2;
VCYL = newv;
Cylinder(VCYL) = {0, 0, -0.5*cgap-cD, 0, 0, cD, 0.5*cdia, 2*Pi};
SLCYL[] = Boundary{Volume{VCYL};};
VCUBOIDWOELECTRODES = newv;
BooleanDifference(VCUBOIDWOELECTRODES) = { Volume{VCUBOID}; Delete; }{ Volume{VTORUS,VCYL}; Delete; };
Physical Surface(TORUSSURFACE) = {SLTORUS[]};
Physical Surface(CYLINDERSURFACE) = {SLCYL[]};
Physical Surface(CUBOIDELECTRODESURFACE) = {SLCUBOID[],SLTORUS[],SLCYL[]};
Physical Volume(CUBOIDELECTRODEVOLUME) = {VCUBOIDWOELECTRODES};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Selection_005.png
Type: image/png
Size: 110810 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20190829/d023e73e/attachment-0001.png>
More information about the gmsh
mailing list