Exemplo n.º 1
0
 private void leaveOneSolverDictionaryOnFvSolution(Dictionary fvSolution) {
   if (fvSolution.found(SolverFamily.SIMPLE.getKey())) {
     if (fvSolution.found(SolverFamily.PIMPLE.getKey())
         || fvSolution.found(SolverFamily.PISO.getKey())
         || fvSolution.found(SolverFamily.CENTRAL.getKey())) {
       fvSolution.remove(SolverFamily.SIMPLE.getKey());
     }
   }
 }
 @Override
 public void load() {
   clear();
   Dictionary dict = dictionaryModel.getDictionary();
   if (dict.found(DATA_KEY)) {
     if (dict.isList2(DATA_KEY)) {
       // Fix for alpha1 which is read with DictionaryReader2
       loadTable(ListField2.convertToString(dict.getList2(DATA_KEY)));
     } else {
       loadTable(dict.lookup(DATA_KEY).trim());
     }
   }
 }
Exemplo n.º 3
0
 static Dictionary extractModule(
     DefaultsProvider defaults, String encodedPrimalState, String moduleName) {
   if (defaults.getDefaultStateData().found(moduleName)) {
     Dictionary defaultModule = new Dictionary(defaults.getDefaultStateData().subDict(moduleName));
     Dictionary relativeToStateModule =
         extractRelativeToStateModule(encodedPrimalState, defaultModule);
     if (relativeToStateModule != null) {
       defaultModule.merge(relativeToStateModule);
     }
     return defaultModule;
   }
   return null;
 }
Exemplo n.º 4
0
  /**
   * @param stringOfState for example "(steady incompressible ras)"
   * @return for example "simpleFoam"
   */
  public String toPrimalState(State state) {
    String state2String = state.state2String();

    Dictionary statesDict = getStates();

    // System.out.println("AbstractDefaultsProvider.toPrimalState() "+statesDict);

    if (statesDict != null) {
      Map<String, String> STATES = Util.invertMap(statesDict.getFieldsMap());

      if (STATES.containsKey(state2String)) {
        return STATES.get(state2String);
      } else {
        logger.warn("[ {} Provider ]: State '{}' NOT AVAILABLE", getName(), state2String);
        return null;
      }
    } else {
      logger.warn("[ {} Provider ]: State '{}' NOT AVAILABLE", getName(), state2String);
      return null;
    }
  }
Exemplo n.º 5
0
  private void fixPIMPLE_CENTRALSolver(Model model) {
    State state = model.getState();
    if (state.isTransient() && state.isCompressible() && state.isHighMach()) {
      SystemFolder systemFolder = model.getProject().getSystemFolder();
      if (isCENTRAL() && state.getSolverFamily().isPimple()) {
        state.setSolverFamily(SolverFamily.CENTRAL);
        solversTable.updateSolver(state);
        ModulesUtil.updateSolver(modules, state);

        Dictionary stateData = model.getDefaults().getDefaultsFor(state);
        Dictionary solutionDict = stateData.subDict(SYSTEM).subDict(FV_SOLUTION);
        Dictionary schemesDict = stateData.subDict(SYSTEM).subDict(FV_SCHEMES);

        systemFolder.setFvSolution(solutionDict);
        systemFolder.setFvSchemes(schemesDict);

        model.solverChanged();
      } else if (isPIMPLE() && state.getSolverFamily().isCentral()) {
        state.setSolverFamily(SolverFamily.PIMPLE);
        solversTable.updateSolver(state);
        ModulesUtil.updateSolver(modules, state);

        Dictionary stateData = model.getDefaults().getDefaultsFor(state);
        Dictionary solutionDict = stateData.subDict(SYSTEM).subDict(FV_SOLUTION);
        Dictionary schemesDict = stateData.subDict(SYSTEM).subDict(FV_SCHEMES);

        systemFolder.setFvSolution(solutionDict);
        systemFolder.setFvSchemes(schemesDict);

        model.solverChanged();
      }
    }
  }
Exemplo n.º 6
0
  private void fixPIMPLE_PISOSolver(Model model) {
    State state = model.getState();
    if (state.isTransient() && state.isIncompressible()) {
      SystemFolder systemFolder = model.getProject().getSystemFolder();
      Dictionary fvSolution = systemFolder.getFvSolution();

      Dictionary stateData = model.getDefaults().getDefaultStateData();
      Dictionary pisoSolution =
          stateData.subDict("pisoFoamRAS").subDict(SYSTEM).subDict(FV_SOLUTION);
      Dictionary pimpleSolution =
          stateData.subDict("pimpleFoamRAS").subDict(SYSTEM).subDict(FV_SOLUTION);

      if (isPISO() && fvSolution.found(SolverFamily.PIMPLE.getKey())) {
        systemFolder.setFvSolution(pisoSolution);
        state.setSolverFamily(SolverFamily.PISO);
        solversTable.updateSolver(state);
        ModulesUtil.updateSolver(modules, state);
        model.solverChanged();
      } else if (isPIMPLE() && fvSolution.found(SolverFamily.PISO.getKey())) {
        systemFolder.setFvSolution(pimpleSolution);
        state.setSolverFamily(SolverFamily.PIMPLE);
        solversTable.updateSolver(state);
        ModulesUtil.updateSolver(modules, state);
        model.solverChanged();
      }
    }
  }
Exemplo n.º 7
0
  private Dictionary mergeBase(String subDictID) {
    Dictionary baseDict = new Dictionary(subDictID);
    Dictionary stateData = getDefaultStateData();

    if (stateData != null && stateData.found(subDictID)) {
      baseDict.merge(stateData.subDict(subDictID));
    } else {
      logger.warn("'" + subDictID + "' NOT FOUND");
    }

    // System.out.println("AbstractDefaultsProvider.mergeBase() "+baseDict);

    if (baseDict.found("base")) {
      String baseName = baseDict.lookup("base");
      Dictionary bd = mergeBase(baseName);
      bd.merge(baseDict);
      return bd;
    }

    return baseDict;
  }
Exemplo n.º 8
0
 private static Dictionary extractRelativeToStateModule(
     String encodedPrimalState, Dictionary mDict) {
   if (mDict.found("requirements")) {
     Dictionary requirements = (Dictionary) mDict.remove("requirements");
     if (requirements.found("conditional")) {
       if (requirements.subDict("conditional").found(encodedPrimalState)) {
         Dictionary conditional = requirements.subDict("conditional").subDict(encodedPrimalState);
         return conditional;
       }
     }
   }
   return null;
 }