Exemplo n.º 1
0
void read_cladistic_tensor(std::ifstream& inFile,
                           RealTensor& F,
                           StateTreeVector& S)
{
  g_lineNumber = 0;
  
  inFile >> F;
  F.setLabels(inFile);
  std::string line;
  gm::getline(inFile, line);
  
  S = StateTreeVector(F.n(), StateTree(F.k()));
  
  for (int c = 0; c < F.n(); ++c)
  {
    try
    {
      inFile >> S[c];
    }
    catch (std::runtime_error& e)
    {
      std::cerr << "State tree file. " << getLineNumber() << e.what() << std::endl;
      exit(1);
    }
  }
}
Exemplo n.º 2
0
void NonlinearNeoHookeCurrentConfig::calculate_stress()
{
  double mu = E / (2.0 * (1.0 + nu));
  double lambda = E * nu / ((1 + nu) * (1 - 2 * nu));

  Real detF = F.det();
  RealTensor Ft = F.transpose();

  RealTensor C = Ft * F;
  RealTensor b = F * Ft;
  RealTensor identity;
  identity(0, 0) = 1.0; identity(1, 1) = 1.0; identity(2, 2) = 1.0;
  RealTensor invC = C.inverse();

  S = 0.5 * lambda * (detF * detF - 1) * invC + mu * (identity - invC);

  tau = (F * S) * Ft;
  sigma = 1/detF * tau;
}
Exemplo n.º 3
0
void NonlinearNeoHookeCurrentConfig::init_for_qp(VectorValue<Gradient> & grad_u, unsigned int qp) {
  this->current_qp = qp;
  F.zero();
  S.zero();

  {
    RealTensor invF;
    invF.zero();
    for (unsigned int i = 0; i < 3; ++i)
      for (unsigned int j = 0; j < 3; ++j) {
        invF(i, j) += libmesh_real(grad_u(i)(j));
      }
    F.add(inv(invF));

    libmesh_assert_greater (F.det(), -TOLERANCE);
  }

  if (this->calculate_linearized_stiffness) {
    this->calculate_tangent();
  }

  this->calculate_stress();
}
Exemplo n.º 4
0
void NoisyCnaEnumerate::fixTrunk(const RealTensor& F_ub,
                                 const StateTreeVector& S,
                                 const StlIntVector& mapNewCharToOldChar,
                                 const StlIntVector& mapOldCharToNewChar,
                                 RootedCladisticNoisyAncestryGraph& G)
{
  const int m = F_ub.m();
  const int k = F_ub.k();
  const int n = F_ub.n();
  
  typedef std::set<IntPair> IntPairSet;
  
  IntPairSet truncalCharacters;
  for (int c = 0; c < n; ++c)
  {
    std::cerr << "Character " << _M(0, mapNewCharToOldChar[c]).characterLabel() << " (" << mapNewCharToOldChar[c] << ") : ";
    S[c].writeEdgeList(std::cerr);
    std::cerr << std::endl;
    
    bool truncal = true;
    int mutation_i = -1;
    for (int p = 0; p < m; ++p)
    {
      double ccf = 0;
      for (int i = 0; i < k; ++i)
      {
        if (!S[c].isPresent(i))
          continue;
        
        const auto& xyz = _M.stateToTriple(i);
        if (xyz._z >= 1)
        {
          ccf += F_ub(i, p, c);
          
          const auto& pi_xyz = _M.stateToTriple(S[c].parent(i));
          if (pi_xyz._z == 0 && xyz._z == 1)
          {
            mutation_i = i;
          }
        }
      }
      ccf /= _purityValues[p];
      
      if (g_tol.less(ccf, 1))
      {
        truncal = false;
        break;
      }
    }
    
    if (truncal)
    {
      assert(mutation_i != -1);
      const StateTree& S_c = S[c];
      truncalCharacters.insert(IntPair(c, mutation_i));
      while ((mutation_i = S_c.parent(mutation_i)) != 0)
      {
        truncalCharacters.insert(IntPair(c, mutation_i));
      }
    }
  }
  
  std::cerr << "Truncal:" << std::endl;
  for (auto ci : truncalCharacters)
  {
    auto xyz = _M.stateToTriple(ci.second);
    std::cerr << _M(0, mapNewCharToOldChar[ci.first]).characterLabel()
              << " , (" << xyz._x << "," << xyz._y << "," << xyz._z << ")" << std::endl;
  }
  
  Digraph::Node monoClonalRoot = G.collapse(truncalCharacters);
  G.makeMonoclonal(monoClonalRoot);
}