fluidsim.base.state
State of the variables (fluidsim.base.state
)
Provides:
- class fluidsim.base.state.StateBase(sim, oper=None)[source]
Bases:
object
Contains the state variables and handles the access to fields.
- Parameters:
- simchild of
fluidsim.base.solvers.base.SimulBase
- operOptional[operators]
- simchild of
- static _complete_info_solver(info_solver)[source]
Complete the ParamContainer info_solver.
This is a static method!
- has_vars(*keys)[source]
Checks if all of the keys are present in the union of
keys_state_phys
andkeys_computable
.- Parameters:
- keys: str, str …
Strings indicating state variable names.
- Returns:
- bool
Examples
>>> sim.state.has_vars('ux', 'uy') >>> sim.state.has_vars('ux') >>> sim.state.has_vars('ux', 'vx', strict=False)
Todo
strict=True
can be a Python 3 compatible keywords-only argument with the function like:def has_vars(self, *keys, strict=True): ... if strict: return keys.issubset(keys_state) else: return len(keys.intersection(keys_state)) > 0 When ``True``, checks if all keys form a subset of state keys. When ``False``, checks if the intersection of the keys and the state keys has atleast one member.
- get_var(key)[source]
Get a physical variable (from the storage array or computed).
This is one of the main method of the state classes.
It tries to return the array corresponding to a physical variable. If it is stored in the main storage array of the state class, it is directly returned. Otherwise, we try to compute the quantity with the method
compute()
.It should not be necessary to redefine this method in child class.
- class fluidsim.base.state.StatePseudoSpectral(sim, oper=None)[source]
Bases:
StateBase
Contains the state variables and handles the access to fields.
This is the general class for the pseudo-spectral solvers.
- Parameters:
- simchild of
fluidsim.base.solvers.base.SimulBase
- operOptional[operators]
- simchild of
- static _complete_info_solver(info_solver)[source]
Complete the ParamContainer info_solver.
This is a static method!
- has_vars(*keys)[source]
Checks if all of the keys are present in the union of
keys_state_phys
,keys_computable
, andkeys_state_spect
.- Parameters:
- keys: str, str …
Strings indicating state variable names.
- Returns:
- bool
Examples
>>> sim.state.has_vars('ux', 'uy', 'ux_fft') >>> sim.state.has_vars('rot')
- get_var(key)[source]
Get a variable (from the storage arrays or computed).
This is one of the main method of the state classes.
It tries to return the array corresponding to a physical variable. If it is stored in the main storage arrays (state_phys and state_spec) of the state class, it is directly returned. Otherwise, we try to compute the quantity with the method
compute()
.It should not be necessary to redefine this method in child class.
- statespect_from_statephys()[source]
Compute the spectral variables from the physical variables.
When you implement a new solver, check that this method does the job!
- statephys_from_statespect()[source]
Compute the physical variables from the spectral variables.
When you implement a new solver, check that this method does the job!
- return_statephys_from_statespect(state_spect=None)[source]
Return the physical variables computed from the spectral variables.
- can_this_key_be_obtained(key)[source]
To check whether a variable can be obtained.
Deprecated since version 0.2.0: Use
has_vars
method instead.
- init_statespect_from(**kwargs)[source]
Initialize state_spect from arrays.
- Parameters:
- **kwargs{key: array, …}
keys and arrays used for the initialization. The other keys are set to zero.
Examples
kwargs = {'a_fft': Fa_fft} init_statespect_from(**kwargs) ux_fft, uy_fft, eta_fft = oper.uxuyetafft_from_qfft(q_fft) init_statespect_from(ux_fft=ux_fft, uy_fft=uy_fft, eta_fft=eta_fft)
Classes
|
Contains the state variables and handles the access to fields. |
|
Contains the state variables and handles the access to fields. |