MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / Copy

Class Copy

dedalus/core/operators.py:1492–1530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1490
1491
1492class Copy(LinearOperator):
1493
1494 name = "Copy"
1495
1496 def __init__(self, operand, out=None):
1497 super().__init__(operand, out=out)
1498 if isinstance(operand, (LockedField, FutureLockedField)):
1499 raise ValueError("Not yet implemented for locked fields.")
1500 # LinearOperator requirements
1501 self.operand = operand
1502 # FutureField requirements
1503 self.domain = operand.domain
1504 self.tensorsig = operand.tensorsig
1505 self.dtype = operand.dtype
1506
1507 def matrix_dependence(self, *vars):
1508 return self.operand.matrix_dependence(*vars)
1509
1510 def matrix_coupling(self, *vars):
1511 return self.operand.matrix_coupling(*vars)
1512
1513 def new_operand(self, operand, **kw):
1514 return Copy(operand, **kw)
1515
1516 def check_conditions(self):
1517 return True
1518
1519 def enforce_conditions(self):
1520 pass
1521
1522 def subproblem_matrix(self, subproblem):
1523 size = subproblem.field_size(self.operand)
1524 return sparse.identity(size, format='csr')
1525
1526 def operate(self, out):
1527 """Perform operation."""
1528 arg = self.args[0]
1529 out.preset_layout(arg.layout)
1530 np.copyto(out.data, arg.data)
1531
1532
1533class Convert(SpectralOperator, metaclass=MultiClass):

Callers 2

add_taskMethod · 0.85
new_operandMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected