Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Solution initialization. #636

Merged
merged 1 commit into from
Nov 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/pyclaw/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Solution(object):
- (:class:`~pyclaw.geometry.Dimension`) - A domain and
patch is created with the dimensions or list of
dimensions provided.
3. `args` is a variable number of arguments that describes the
3. `args` is a variable number of keyword arguments that describes the
location of a file to be read in to initialize the object

:Examples:
Expand Down Expand Up @@ -140,17 +140,14 @@ def get_clawpack_dot_xxx(modname): return modname.rpartition('.')[0]
frame = arg[0]
if not isinstance(frame,int):
raise Exception('Invalid pyclaw.Solution object initialization')
if 'count_from_zero' in list(kargs.keys()) and\
kargs['count_from_zero'] == True:
self._start_frame = 0
else:
self._start_frame = frame
try:
if ('count_from_zero' in kargs):
if (kargs['count_from_zero'] == True):
self._start_frame = 0
else:
self._start_frame = frame
kargs.pop('count_from_zero')
except KeyError:
pass

self.read(frame,**kargs)

elif len(arg) == 2:
#Set domain
if isinstance(arg[1],Domain):
Expand All @@ -163,7 +160,7 @@ def get_clawpack_dot_xxx(modname): return modname.rpartition('.')[0]
elif isinstance(arg[1][0],Patch):
self.domain = Domain(arg[1])
else:
raise Exception("Invalid argument list")
raise Exception("Invalid arguments for Solution initialization.")

#Set state
if isinstance(arg[0],State):
Expand All @@ -176,11 +173,21 @@ def get_clawpack_dot_xxx(modname): return modname.rpartition('.')[0]
elif isinstance(arg[0][0],int):
self.states = State(self.domain,arg[0][0],arg[0][1])
else:
raise Exception("Invalid argument list")
raise Exception("Invalid arguments for Solution initialization.")
elif isinstance(arg[0],int):
self.states.append(State(self.domain,arg[0]))
if self.states == [] or self.domain is None:
raise Exception("Invalid argument list")
raise Exception("Invalid arguments for Solution initialization.")
elif len(arg) == 0:
if 'frame' in kargs:
frame = kargs.pop('frame')
self.read(frame,**kargs)
elif not kargs:
pass # With no arguments, initialize empty solution
else:
raise Exception("Invalid arguments for Solution initialization.")
else:
raise Exception("Invalid arguments for Solution initialization.")


def is_valid(self):
Expand Down