Source code for Muscat.FE.KR.KRDofs
# -*- coding: utf-8 -*-
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.txt', which is part of this source code package.
#
from Muscat.FE.KR.KRBase import KRBase
[docs]
class KRDofs(KRBase):
def __init__(self):
super().__init__()
[docs]
def GenerateEquations(self, meshI=None, fields=None, CH=None, meshII=None, fieldsII=None):
if CH is None:
from Muscat.LinAlg.ConstraintsHolder import ConstraintsHolder
CH = ConstraintsHolder()
ei, ej, ev = self.GetIsJsVs()
CH.AddEquationsFromIJV(ei, ej, ev)
return CH
[docs]
def GetIsJsVs(self): # pragma: no cover
raise NotImplementedError("Function not implemented, please subclass")
[docs]
def CheckIntegrity(GUI: bool = False):
class KRDofsTest(KRDofs):
def __init__(self):
super().__init__()
def GetIsJsVs(self):
ei = [0, 0, 1, 1, 2, 2, 3, 3]
ej = [1, 4, 2, 7, 10, 15, 9, 12]
ev = [1, -1, 1, -1, 1, -1, 1, -1]
return ei, ej, ev
obj = KRDofsTest()
ch = obj.GenerateEquations()
ch.SetNumberOfDofs(20)
ch.Compact()
mat, dofs = ch.ToSparse()
print(mat.toarray())
print(dofs)
return "ok"
if __name__ == "__main__":
print(CheckIntegrity(GUI=True)) # pragma: no cover