Changeset 0d11bbe in OpenModelica


Ignore:
Timestamp:
2016-04-08T13:46:23+02:00 (8 years ago)
Author:
ptaeuber <patrick_marcel.taeuber@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
027b44e2
Parents:
fc4de9ec
git-author:
ptaeuber <patrick_marcel.taeuber@…> (04/08/16 12:50:33)
git-committer:
ptaeuber <patrick_marcel.taeuber@…> (04/08/16 13:46:23)
Message:

Introduce indexing of strong components

Allows access to single components e.g. to deactivate tearing or
to use a user defined tearing for selected components

Location:
Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Compiler/BackEnd/Tearing.mo

    r7d8f15f2 r0d11bbe  
    6060protected import ExpressionSolve;
    6161protected import Flags;
     62protected import Global;
    6263protected import List;
    6364protected import Matching;
     
    9697      TearingMethod method;
    9798      BackendDAE.BackendDAEType DAEtype;
     99      Integer strongComponentIndex = System.tmpTickIndex(Global.strongComponent_index);
    98100
    99101    // if noTearing is selected, do nothing.
     
    105107    // get method function and traverse systems
    106108    case(_) equation
     109
    107110      methodString = Config.getTearingMethod();
    108111      BackendDAE.SHARED(backendDAEType=DAEtype) = inDAE.shared;
     
    114117        print("!\n" + UNDERLINE + UNDERLINE + "\n");
    115118      end if;
    116       (outDAE, _) = BackendDAEUtil.mapEqSystemAndFold(inDAE, tearingSystemWork, method);
     119      (outDAE, (_,strongComponentIndex)) = BackendDAEUtil.mapEqSystemAndFold(inDAE, tearingSystemWork, (method, strongComponentIndex));
     120      System.tmpTickSetIndex(strongComponentIndex, Global.strongComponent_index);
    117121    then outDAE;
    118122
     
    185189  input BackendDAE.EqSystem isyst;
    186190  input BackendDAE.Shared inShared;
    187   input TearingMethod inTearingMethod;
     191  input tuple<TearingMethod,Integer> inTearingMethodAndIndex;
    188192  output BackendDAE.EqSystem osyst;
    189193  output BackendDAE.Shared outShared = inShared "unused";
    190   output TearingMethod outTearingMethod = inTearingMethod "unused";
    191 protected
     194  output tuple<TearingMethod,Integer> outTearingMethodAndIndex;
     195protected
     196  TearingMethod inTearingMethod = Util.tuple21(inTearingMethodAndIndex);
     197  Integer strongComponentIndex = Util.tuple22(inTearingMethodAndIndex);
    192198  BackendDAE.StrongComponents comps;
    193199  Boolean b;
     
    198204    print("\n" + BORDER + "\nBEGINNING of traverseComponents\n\n");
    199205  end if;
    200   (comps, b) := traverseComponents(comps, isyst, inShared, inTearingMethod);
     206  (comps, b, strongComponentIndex) := traverseComponents(comps, isyst, inShared, inTearingMethod, strongComponentIndex);
    201207  if Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
    202208    print("\nEND of traverseComponents\n" + BORDER + "\n\n");
    203209  end if;
    204210  osyst := if b then BackendDAEUtil.setEqSystMatching(isyst, BackendDAE.MATCHING(ass1, ass2, comps)) else isyst;
     211  outTearingMethodAndIndex := (inTearingMethod,strongComponentIndex);
    205212end tearingSystemWork;
    206213
     
    210217  input BackendDAE.Shared ishared;
    211218  input TearingMethod inMethod;
     219  input Integer strongComponentIndexIn;
    212220  output BackendDAE.StrongComponents oComps;
    213221  output Boolean outRunMatching = false;
     222  output Integer strongComponentIndexOut=strongComponentIndexIn;
    214223algorithm
    215224  oComps := list(match co
     
    219228        case comp
    220229          equation
    221             (comp, b) = traverseComponents1(comp, isyst, ishared, inMethod);
     230            (comp, b, strongComponentIndexOut) = traverseComponents1(comp, isyst, ishared, inMethod, strongComponentIndexOut);
    222231            outRunMatching = outRunMatching or b;
    223232          then comp;
     
    230239  input BackendDAE.Shared ishared;
    231240  input TearingMethod inMethod;
     241  input Integer strongComponentIndexIn;
    232242  output BackendDAE.StrongComponent oComp;
    233243  output Boolean outRunMatching;
     244  output Integer strongComponentIndexOut=strongComponentIndexIn;
    234245protected
    235246  constant Boolean debug = false;
    236247algorithm
     248  strongComponentIndexOut := match(inComp)
     249    case(BackendDAE.EQUATIONSYSTEM(jac=BackendDAE.FULL_JACOBIAN())) equation
     250      if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
     251        print("Handle strong component with index: " + intString(strongComponentIndexOut+1) + "\nTo disable tearing of this component use '--noTearingForComponent=" + intString(strongComponentIndexOut+1) + "'.\n");
     252      end if;
     253     then (strongComponentIndexOut + 1);
     254    else strongComponentIndexOut;
     255  end match;
     256
    237257  (oComp, outRunMatching) := matchcontinue (inComp, isyst, ishared, inMethod)
    238258    local
     
    254274      end if;
    255275      if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
    256         print("\nCase linear in traverseComponents\nUse Flag '+d=tearingdumpV' for more details\n\n");
     276        print("\nTearing of LINEAR component\nUse Flag '+d=tearingdumpV' for more details\n\n");
    257277      end if;
    258278      false = Flags.getConfigBool(Flags.DISABLE_LINEAR_TEARING);
     
    278298      end if;
    279299      if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
    280         print("\nCase non-linear in traverseComponents\nUse Flag '+d=tearingdumpV' for more details\n\n");
     300        print("\nTearing of NONLINEAR component\nUse Flag '+d=tearingdumpV' for more details\n\n");
    281301      end if;
    282302      if Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
  • Compiler/Global/Global.mo

    r8f17d04 r0d11bbe  
    7373// csevar name
    7474constant Integer backendDAE_cseIndex = 23;
     75// strong component index
     76constant Integer strongComponent_index = 24;
    7577
    7678// ----------------------
Note: See TracChangeset for help on using the changeset viewer.