Skip to content
Snippets Groups Projects
Commit df4c533c authored by Nicolas Marsic's avatar Nicolas Marsic
Browse files

allow -setnumber

parent 05f6351b
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem, ...@@ -4,7 +4,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem,
Institut fuer Theorie Elektromagnetischer Felder (TEMF), Institut fuer Theorie Elektromagnetischer Felder (TEMF),
Technische Universitaet Darmstadt. Technische Universitaet Darmstadt.
See the LICENSE.txt and README.txt for more license and copyright information. See the LICENSE.txt and README.md for more license and copyright information.
""" """
import argparse import argparse
...@@ -17,6 +17,7 @@ def parse(): ...@@ -17,6 +17,7 @@ def parse():
# Initialise # Initialise
parser = argparse.ArgumentParser(prog="cim.py", parser = argparse.ArgumentParser(prog="cim.py",
description=desc, description=desc,
formatter_class=MyFormatter,
epilog="authors: " + epilog="authors: " +
"N. Marsic, F. Wolf, " + "N. Marsic, F. Wolf, " +
"S. Schoeps and H. De Gersem") "S. Schoeps and H. De Gersem")
...@@ -44,6 +45,9 @@ def parse(): ...@@ -44,6 +45,9 @@ def parse():
help="step size for increasing col(A0)") help="step size for increasing col(A0)")
parser.add_argument("-rankTol", type=float, default=1e-4, parser.add_argument("-rankTol", type=float, default=1e-4,
help="relative tolerance for rank test") help="relative tolerance for rank test")
parser.add_argument("-setnumber", type=str, default=[], action='append',
nargs=2, metavar=('NAME', 'VALUE'),
help="set constant number NAME=VALUE")
parser.add_argument("-quiet", action='store_true', parser.add_argument("-quiet", action='store_true',
help="should I be quiet?") help="should I be quiet?")
...@@ -51,10 +55,31 @@ def parse(): ...@@ -51,10 +55,31 @@ def parse():
return parser.parse_args() return parser.parse_args()
## Import only parse (other functions are just helpers)
__all__ = ['parse']
## Helper
desc = ("a non-linear eigenvalue solver " + desc = ("a non-linear eigenvalue solver " +
"using the contour integral method proposed by W.-J. Beyn " + "using the contour integral method proposed by W.-J. Beyn " +
"coupled with a GetDP formulation.") "coupled with a GetDP formulation.")
## Import only parse (other functions are just helpers) class MyFormatter(argparse.HelpFormatter):
__all__ = ['parse'] """ Custom Formatter
"""
def __init__(self, prog):
super(MyFormatter, self).__init__(prog,
indent_increment=2,
max_help_position=30,
width=None)
def _get_help_string(self, action):
help = action.help
if '%(default)' not in action.help:
if action.default is not argparse.SUPPRESS:
defaulting_nargs = [argparse.OPTIONAL, argparse.ZERO_OR_MORE]
if action.option_strings or action.nargs in defaulting_nargs:
help += ' (default: %(default)s)'
return help
...@@ -4,7 +4,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem, ...@@ -4,7 +4,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem,
Institut fuer Theorie Elektromagnetischer Felder (TEMF), Institut fuer Theorie Elektromagnetischer Felder (TEMF),
Technische Universitaet Darmstadt. Technische Universitaet Darmstadt.
See the LICENSE.txt and README.txt for more license and copyright information. See the LICENSE.txt and README.md for more license and copyright information.
""" """
import solver as Solver import solver as Solver
......
...@@ -5,7 +5,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem, ...@@ -5,7 +5,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem,
Institut fuer Theorie Elektromagnetischer Felder (TEMF), Institut fuer Theorie Elektromagnetischer Felder (TEMF),
Technische Universitaet Darmstadt. Technische Universitaet Darmstadt.
See the LICENSE.txt and README.txt for more license and copyright information. See the LICENSE.txt and README.md for more license and copyright information.
""" """
import solver as Solver import solver as Solver
...@@ -16,8 +16,15 @@ import args as args ...@@ -16,8 +16,15 @@ import args as args
# Parse arguments # Parse arguments
arg = args.parse() arg = args.parse()
# Prepare variables of -setnumber for GetDP
setnumber = []
for i in arg.setnumber:
setnumber.append("-setnumber")
for j in i:
setnumber.append(j)
# Initialise GetDP # Initialise GetDP
operator = Solver.GetDPWave(arg.pro, arg.mesh, arg.resolution) operator = Solver.GetDPWave(arg.pro, arg.mesh, arg.resolution, setnumber)
# Compute # Compute
l, V, r = Beyn.simple(operator, arg.origin, arg.radius, l, V, r = Beyn.simple(operator, arg.origin, arg.radius,
......
...@@ -4,7 +4,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem, ...@@ -4,7 +4,7 @@ Copyright (C) 2017 N. Marsic, F. Wolf, S. Schoeps and H. De Gersem,
Institut fuer Theorie Elektromagnetischer Felder (TEMF), Institut fuer Theorie Elektromagnetischer Felder (TEMF),
Technische Universitaet Darmstadt. Technische Universitaet Darmstadt.
See the LICENSE.txt and README.txt for more license and copyright information. See the LICENSE.txt and README.md for more license and copyright information.
""" """
import getdp as GetDP import getdp as GetDP
...@@ -26,24 +26,29 @@ class GetDPWave: ...@@ -26,24 +26,29 @@ class GetDPWave:
fileName -- post-processing file name fileName -- post-processing file name
""" """
def __init__(self, pro, mesh, resolution): def __init__(self, pro, mesh, resolution, optional=[]):
"""Instanciates a new SolverGetDP with a full '-solve' """Instanciates a new SolverGetDP with a full '-solve'
Keyword arguments: Keyword arguments:
pro -- the .pro file to use pro -- the .pro file to use
mesh -- the .msh file to use mesh -- the .msh file to use
resolution -- the resolution (from the .pro file) to use resolution -- the resolution (from the .pro file) to use
optional -- optional arguments for GetDP (default value = [])
Optional argument has the following structure:
["GetDP option", "value 1", "value 2", ..., "GetDP option", ...]
""" """
# Save # Save
self.__pro = pro self.__pro = pro
self.__mesh = mesh self.__mesh = mesh
self.__resolution = resolution self.__resolution = resolution
self.__optional = optional
# Generate DoFs and initialise RHS and solution vectors in GetDP # Generate DoFs and initialise RHS and solution vectors in GetDP
GetDP.GetDP(["getdp", self.__pro, GetDP.GetDP(["getdp", self.__pro,
"-msh", self.__mesh, "-msh", self.__mesh,
"-solve", self.__resolution, "-solve", self.__resolution,
"-v", "2"]) "-v", "2"] + self.__optional)
def solution(self): def solution(self):
"""Returns the solution""" """Returns the solution"""
...@@ -64,7 +69,7 @@ class GetDPWave: ...@@ -64,7 +69,7 @@ class GetDPWave:
GetDP.GetDPSetNumber("doApply", 1) GetDP.GetDPSetNumber("doApply", 1)
GetDP.GetDP(["getdp", self.__pro, GetDP.GetDP(["getdp", self.__pro,
"-msh", self.__mesh, "-msh", self.__mesh,
"-cal"]) "-cal"] + self.__optional)
GetDP.GetDPSetNumber("doApply", 0) GetDP.GetDPSetNumber("doApply", 0)
def solve(self, b, w): def solve(self, b, w):
...@@ -75,7 +80,7 @@ class GetDPWave: ...@@ -75,7 +80,7 @@ class GetDPWave:
GetDP.GetDPSetNumber("imposeRHS", 1) GetDP.GetDPSetNumber("imposeRHS", 1)
GetDP.GetDP(["getdp", self.__pro, GetDP.GetDP(["getdp", self.__pro,
"-msh", self.__mesh, "-msh", self.__mesh,
"-cal"]) "-cal"] + self.__optional)
GetDP.GetDPSetNumber("imposeRHS", 0) GetDP.GetDPSetNumber("imposeRHS", 0)
def view(self, x, fileName): def view(self, x, fileName):
...@@ -92,7 +97,7 @@ class GetDPWave: ...@@ -92,7 +97,7 @@ class GetDPWave:
GetDP.GetDPSetString("fileName", fileName) GetDP.GetDPSetString("fileName", fileName)
GetDP.GetDP(["getdp", self.__pro, GetDP.GetDP(["getdp", self.__pro,
"-msh", self.__mesh, "-msh", self.__mesh,
"-cal"]) "-cal"] + self.__optional)
GetDP.GetDPSetNumber("doPostpro", 0) GetDP.GetDPSetNumber("doPostpro", 0)
@staticmethod @staticmethod
......
...@@ -6,7 +6,7 @@ init: ...@@ -6,7 +6,7 @@ init:
gmsh sphere.geo -3 gmsh sphere.geo -3
cim: cim:
python ${BIN}/cim.py sphere.pro sphere.msh Solve 8.22543e9+2.46361e1j 1e8 -nodes 10 -lStart 4 python ${BIN}/cim.py sphere.pro sphere.msh Solve 8.22543e9+2.46361e1j 1e8 -nodes 10 -lStart 4 -setnumber isSC 0
clean: clean:
rm -f *.pos rm -f *.pos
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment