Newer
Older

Nicolas Marsic
committed
Group{
Omega = Region[1]; // Domain
Bndry = Region[2]; // Boundary
}
Function{
// Physical data //
DefineConstant[angularFreqRe = 5, // [rad/s]
angularFreqIm = 0]; // [rad/s]
C0 = 299792458; // [m/s]
aFC[] = Complex[angularFreqRe,
angularFreqIm]; // [rad/m]
k[] = aFC[]/C0; // [rad/m]
Printf["Angular frequency set to: %g + i*%g [rad/s]",
angularFreqRe, angularFreqIm];
// Algebraic data //
DefineConstant[nRHS = 1]; // Number of RHS for this run
For i In {0:nRHS-1}
DefineConstant[x~{i}() = {}, // Solution
b~{i}() = {}]; // Right hand side
EndFor

Nicolas Marsic
committed
// Control data //
DefineConstant[doInit = 0, // Should I initialize some stuff?
doSolve = 0, // Should I solve Ax = b?

Nicolas Marsic
committed
doPostpro = 0, // Should I only create a view for x()?
doApply = 0, // Should I only apply x(): x <- Ax?

Nicolas Marsic
committed
fileName = "eig.pos"]; // Postpro file name

Nicolas Marsic
committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
}
Jacobian{
{ Name JVol;
Case{
{ Region All; Jacobian Vol; }
}
}
}
Integration{
{ Name IP2;
Case{
{ Type Gauss;
Case{
{ GeoElement Line; NumberOfPoints 2; }
{ GeoElement Triangle; NumberOfPoints 3; }
{ GeoElement Tetrahedron; NumberOfPoints 4; }
}
}
}
}
}
Constraint{
{ Name Dirichlet; Type Assign;
Case{
{ Region Bndry; Value 0; }
}
}
}
FunctionSpace{
{ Name HCurl; Type Form1;
BasisFunction{ // Nedelec
{ Name se; NameOfCoef ee; Function BF_Edge;
Support Omega; Entity EdgesOf[All]; }
}
Constraint{
{ NameOfCoef ee; EntityType EdgesOf; NameOfConstraint Dirichlet; }
}
}
}
Formulation{
{ Name Maxwell; Type FemEquation;
Quantity{
{ Name e; Type Local; NameOfSpace HCurl; }
}
Equation{
Galerkin{ [ Dof{d e} , {d e}];
In Omega; Integration IP2; Jacobian JVol; }
Galerkin{ [-k[]^2 * Dof{ e} , { e}];
In Omega; Integration IP2; Jacobian JVol; }
}
}
}
Resolution{
{ Name Maxwell;
System{
{ Name A; NameOfFormulation Maxwell; Type Complex; }
}
Operation{
Generate[A];
If(doInit)
CopySolution[A, x~{0}()];

Nicolas Marsic
committed
EndIf
If(doSolve)
// Full solve for first RHS
CopyRightHandSide[b~{0}(), A];

Nicolas Marsic
committed
Solve[A];
CopySolution[A, x~{0}()];
// SolveAgain for other RHSs
For i In {1:nRHS-1}
CopyRightHandSide[b~{i}(), A];
SolveAgain[A];
CopySolution[A, x~{i}()];
EndFor

Nicolas Marsic
committed
EndIf

Nicolas Marsic
committed
If(doApply)

Nicolas Marsic
committed
Apply[A];

Nicolas Marsic
committed
EndIf

Nicolas Marsic
committed
If(doPostpro)

Nicolas Marsic
committed
PostOperation[Maxwell];

Nicolas Marsic
committed
EndIf

Nicolas Marsic
committed
}
}
}
PostProcessing{
{ Name Maxwell; NameOfFormulation Maxwell;
Quantity{
{ Name e; Value{ Local{ [{e}]; In Omega; Jacobian JVol; } } }
}
}
}
PostOperation{
{ Name Maxwell; NameOfPostProcessing Maxwell;
Operation{

Nicolas Marsic
committed
Print[e, OnElementsOf Omega, File fileName];