Skip to content
Snippets Groups Projects
Commit 4e9a5c3c authored by Matteo Cicuttin's avatar Matteo Cicuttin
Browse files

Reorganized examples.

parent 48b75d6f
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,9 @@ Materials are specified populating the `materials` table exposed by the solver.
#### A note about entity tags
GMSH entities (Volumes, surfaces, ...) are identified by an integer named *tag*. That tag can change for several reasons (version and type of the geometric kernel, GMSH version...), therefore GMSH provides *physical groups* in order to have a more stable numbering and to be able to give a single tag to multiple entities/subdomains. GMSH/DG was originally based on entity tags, but partial support for physical groups is being added. Currently support for physical groups is slightly incoherent and supported only on materials and boundary conditions.
* See `share/examples/resonator/` or `share/examples/scatterer/` for the old way of setting up materials and boundary conditions
* See `share/examples/parallel_plate/` for the setup of materials and boundary conditions using physical groups.
It is possible either to provide a function describing the material properties in the whole domain or specify the materials subdomain by subdomain. In the first case, appropriate callbacks have to be installed in the material table, whereas in the second case the appropriate variables must be set.
If, for example, the model has two subdomains with tags `1` and `2`, the electric permeability can be specified as
......
SetFactory("OpenCASCADE");
Box(1) = {0, 0, 0, 3, 3, 3};
Box(2) = {1+0.3, 1+0.45, 1+0.45, 0.4, 0.1, 0.1};
Coherence;
// Air box
MeshSize {17, 18, 19, 20, 21, 22, 23, 24} = 0.2;
// Metal block
MeshSize {9, 10, 11, 12, 13, 14, 15, 16} = 0.05;
--[[
This example is a simplified version of a more complicated model
of an electrostatic discharge applied to a metallic box.
The discharge is modeled as a surface current source, but this is
not physically correct. This model is more a test for interface
BCs and sources than anything else.
--]]
sim.name = "binde_simplified" -- simulation name
sim.dt = 1e-11 -- timestep size
sim.timesteps = 10000 -- num of iterations
sim.gmsh_model = "binde_simplified.geo" -- gmsh model filename
sim.use_gpu = 0 -- 0: cpu, 1: gpu
sim.approx_order = 1 -- approximation order
--sim_geom_order = 1 -- geometric order, only 1 for now
postpro.silo_output_rate = 10 -- rate at which to write silo files
postpro.cycle_print_rate = 10 -- console print rate
sim.time_integrator = "leapfrog" -- use leapfrog with dissipative materials
-- ** Materials **
-- Aluminum
local alu = {2}
for i,v in ipairs(alu) do
materials[v] = {}
materials[v].epsilon = 1
materials[v].mu = 1
materials[v].sigma = 1
end
local air = {3}
for i,v in ipairs(air) do
materials[v] = {}
materials[v].epsilon = 1
materials[v].mu = 1
materials[v].sigma = 0
end
-- ** Boundary conditions **
local Z_bnds = {13, 14, 15, 16, 17, 18}
for i,v in ipairs(Z_bnds) do
bndconds[v] = {}
bndconds[v].kind = "impedance"
end
-- Linear interpolation
function interp(t, t0, t1, y0, y1)
return (t-t0)*(y1-y0)/(t1-t0) + y0
end
-- Shape of the electrostatic discharge given as time-value pairs
local current_shape = { {0, 0}, {9.5e-9, 0.03}, {1.1e-8, 1},
{1.4e-8, 0.45}, {1.6e-8, 0.45}, {2.7e-8, 0.6},
{9e-8, 0.01}, {1e-7, 0} }
-- Function that evaluates the source
function interface_source_7(tag, x, y, z, t)
for ii = 1,(#current_shape-1) do
local t0 = current_shape[ii][1]
local c0 = current_shape[ii][2]
local t1 = current_shape[ii+1][1]
local c1 = current_shape[ii+1][2]
if (t >= t0 and t < t1) then
Ez = interp(t, t0, t1, c0, c1)
return 0, 0, Ez
end
end
return 0, 0, 0
end
-- Surface current interface condition
local discharge_surf = 7
ifaceconds[discharge_surf] = {}
ifaceconds[discharge_surf].kind = "surface_current"
ifaceconds[discharge_surf].source = interface_source_7
sim.name = "scatterer" -- simulation name
sim.dt = 1e-12 -- timestep size
sim.timesteps = 10001 -- num of iterations
sim.gmsh_model = "scatterer.geo" -- gmsh model filename
sim.use_gpu = 0 -- 0: cpu, 1: gpu
sim.approx_order = 1 -- approximation order
sim.time_integrator = "rk4" -- time integration method
postpro.silo_output_rate = 10 -- rate at which to write silo files
postpro.cycle_print_rate = 10 -- console print rate
local air = {1}
for i,v in ipairs(air) do
materials[v] = {}
materials[v].epsilon = 1
materials[v].mu = 1
materials[v].sigma = 0
end
-- ** Boundary conditions **
local absorbing_bcs = {17, 18, 19, 20, 21}
for i,v in ipairs(absorbing_bcs) do
bndconds[v] = {}
bndconds[v].kind = "impedance"
end
local pmc = {13,14}
for i,v in ipairs(pmc) do
bndconds[v] = {}
bndconds[v].kind = "pmc"
end
local freq = 3e9;
function srcfun(tag, x, y, z, t)
Ez = math.sin(2*math.pi*freq*t)
return 0,0,Ez
end
local source = {12}
for i,v in ipairs(source) do
bndconds[v] = {}
bndconds[v].kind = "plane_wave_E"
bndconds[v].source = srcfun;
end
SetFactory("OpenCASCADE");
Point(1) = {0, -0.05, 0};
Point(2) = {0, 0.05, 0};
Point(3) = {0.2, 0.1, 0};
Point(4) = {0.2, 0.2, 0};
Point(5) = {0.6, 0.2, 0};
Point(6) = {0.6, -0.2, 0};
Point(7) = {0.2, -0.2, 0};
Point(8) = {0.2, -0.1, 0};
Line(1) = {1,2};
Line(2) = {2,3};
Line(3) = {3,4};
Line(4) = {4,5};
Line(5) = {5,6};
Line(6) = {6,7};
Line(7) = {7,8};
Line(8) = {8,1};
Curve Loop(9) = {1,2,3,4,5,6,7,8};
Plane Surface(1) = {9};
Extrude{0,0,0.1}{ Surface{1}; }
Sphere(2) = {0.4, 0, 0.05, 0.02};
BooleanDifference{ Volume{1}; Delete; }{ Volume{2}; Delete; }
MeshSize{ PointsOf{ Volume{1}; } } = 0.01;
MeshSize{ PointsOf{ Surface{11}; } } = 0.005;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment