Exemplo n.º 1
0
TEST_P(TestSIMNodalConstraint, Vertex3D)
{
  if (GetParam() > 8)
    return;

  SIMNodalConstraint<SIM3D> s({2});
  std::stringstream str;
  str << "refdata/nodal_3D_V" << GetParam() << ".xinp";
  ASSERT_TRUE(s.read(str.str().c_str()));
  s.preprocess();

  const ASMs3D& pch = static_cast<const ASMs3D&>(*s.getPatch(1));
  int n1, n2, n3;
  pch.getSize(n1,n2,n3);
  for (size_t i=1; i <= pch.getNoNodes(); ++i) {
    if (i == 1 && GetParam() == 1)
      check_mpc(pch.findMPC(i, 1), n1);
    else if ((i == (size_t)n1 && GetParam() == 2)
          || (i == (size_t)n1*(n2-1)+1 && GetParam() == 3)
          || (i == (size_t)n1*n2 && GetParam() == 4)
          || (i == (size_t)1+n1*n2*(n3-1) && GetParam() == 5)
          || (i == (size_t)n1+n1*n2*(n3-1) && GetParam() == 6)
          || (i == (size_t)1+n1*(n2-1)+n1*n2*(n3-1) && GetParam() == 7)
          || (i == pch.getNoNodes() && GetParam() == 8))
      check_mpc(pch.findMPC(i, 1), 1);
    else
      ASSERT_TRUE(pch.findMPC(i, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i, 2) == nullptr);
  }
}
Exemplo n.º 2
0
TEST_P(TestSIMNodalConstraint, Edge2D)
{
  if (GetParam() > 4)
    return;

  SIMNodalConstraint<SIM2D> s({2});
  std::stringstream str;
  str << "refdata/nodal_2D_E" << GetParam() << ".xinp";
  ASSERT_TRUE(s.read(str.str().c_str()));
  s.preprocess();

  const ASMs2D& pch = static_cast<const ASMs2D&>(*s.getPatch(1));
  int n1, n2;
  pch.getSize(n1,n2);
  for (size_t i=1; i <= pch.getNoNodes(); ++i) {
    if (i % n1 == 1 && GetParam() == 1)
      check_mpc(pch.findMPC(i, 1), n1);
    else if (i % n1 == 0 && GetParam() == 2)
      check_mpc(pch.findMPC(i, 1), 1);
    else if (i <= (size_t)n1 && GetParam() == 3)
      check_mpc(pch.findMPC(i, 1), n1*n2);
    else if (i > (size_t)n1*(n2-1) && GetParam() == 4)
      check_mpc(pch.findMPC(i, 1), 1);
    else
      ASSERT_TRUE(pch.findMPC(i, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i, 2) == nullptr);
  }
}
Exemplo n.º 3
0
TEST_P(TestSIMNodalConstraint, Edge2DLR)
{
  if (GetParam() > 4)
    return;

  auto old = IFEM::getOptions().discretization;
  IFEM::getOptions().discretization = ASM::LRSpline;
  SIMNodalConstraint<SIM2D> s({2});
  std::stringstream str;
  str << "refdata/nodal_2D_E" << GetParam() << ".xinp";
  ASSERT_TRUE(s.read(str.str().c_str()));
  s.preprocess();

  const ASMu2D& pch = static_cast<const ASMu2D&>(*s.getPatch(1));
  static const std::vector<LR::parameterEdge> E
        {LR::WEST, LR::EAST, LR::SOUTH, LR::NORTH};
  auto nodes = pch.getEdgeNodes(E[GetParam()-1], 1);
  for (size_t i=1; i <= pch.getNoNodes(); ++i) {
    if (std::find(nodes.begin(), nodes.end(), i) != nodes.end() &&
        i != (size_t)pch.getCorner(1,-1,1) && GetParam() == 1)
      check_mpc(pch.findMPC(i, 1), pch.getCorner(1,-1,1));
    else if (std::find(nodes.begin(), nodes.end(), i) != nodes.end() && GetParam() == 3)
      check_mpc(pch.findMPC(i, 1), pch.getCorner(1,1,1));
    else if (std::find(nodes.begin(), nodes.end(), i) != nodes.end())
      check_mpc(pch.findMPC(i, 1), 1);
    else
      ASSERT_TRUE(pch.findMPC(i, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i, 2) == nullptr);
  }
  IFEM::getOptions().discretization = old;
}
Exemplo n.º 4
0
TEST_P(TestSIMNodalConstraint, Vertex2DLR)
{
  if (GetParam() > 4)
    return;

  auto old = IFEM::getOptions().discretization;
  IFEM::getOptions().discretization = ASM::LRSpline;
  SIMNodalConstraint<SIM2D> s({2});
  std::stringstream str;
  str << "refdata/nodal_2D_V" << GetParam() << ".xinp";
  ASSERT_TRUE(s.read(str.str().c_str()));
  s.preprocess();

  const ASMu2D& pch = static_cast<const ASMu2D&>(*s.getPatch(1));
  for (size_t i=1; i <= pch.getNoNodes(); ++i) {
    if (i == 1 && GetParam() == 1)
      check_mpc(pch.findMPC(i, 1), pch.getCorner(1,-1,1));
    else if (i == (size_t)pch.getCorner(1,-1,1) && GetParam() == 2)
      check_mpc(pch.findMPC(i, 1), 1);
    else if (i == (size_t)pch.getCorner(-1,1,1) && GetParam() == 3)
      check_mpc(pch.findMPC(i, 1), 1);
    else if (i == (size_t)pch.getCorner(1,1,1) && GetParam() == 4)
      check_mpc(pch.findMPC(i, 1), 1);
    else
      ASSERT_TRUE(pch.findMPC(i, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i, 2) == nullptr);
  }
  IFEM::getOptions().discretization = old;
}
Exemplo n.º 5
0
Arquivo: ovm_cdd.c Projeto: pcpa/owl
void
ovm_dd_div(oregister_t *l, oregister_t *r)
{
    switch (r->t) {
	case t_void:
	    l->v.dd /= 0.0;
	    check_cdd(l);
	    break;
	case t_word:
	    l->v.dd /= r->v.w;
	    check_cdd(l);
	    break;
	case t_float:
	    l->v.dd /= r->v.d;
	    check_cdd(l);
	    break;
	case t_mpz:
	    l->v.dd /= mpz_get_d(ozr(r));
	    check_cdd(l);
	    break;
	case t_rat:
	    l->v.dd /= rat_get_d(r->v.r);
	    check_cdd(l);
	    break;
	case t_mpq:
	    l->v.dd /= mpq_get_d(oqr(r));
	    check_cdd(l);
	    break;
	case t_mpr:
	    l->t = t_mpc;
	    mpc_set_d_d(occ(l), real(l->v.dd), imag(l->v.dd), thr_rndc);
	    mpc_set_fr(occ(r), orr(r), thr_rndc);
	    mpc_div(occ(l), occ(l), occ(r), thr_rndc);
	    check_mpc(l);
	    break;
	case t_cdd:
	    l->v.dd /= r->v.dd;
	    check_cdd(l);
	    break;
	case t_cqq:
	    real(r->v.dd) = mpq_get_d(oqr(r));
	    imag(r->v.dd) = mpq_get_d(oqi(r));
	    l->v.dd /= r->v.dd;
	    check_cdd(l);
	    break;
	case t_mpc:
	    l->t = t_mpc;
	    mpc_set_d_d(occ(l), real(l->v.dd), imag(l->v.dd), thr_rndc);
	    mpc_div(occ(l), occ(l), occ(r), thr_rndc);
	    check_mpc(l);
	    break;
	default:
	    ovm_raise(except_not_a_number);
    }
}
Exemplo n.º 6
0
Arquivo: ovm_cdd.c Projeto: pcpa/owl
void
ovm_dd_atan2(oregister_t *l, oregister_t *r)
{
    switch (r->t) {
	case t_void:
	    goto flt;
	case t_word:
	    if (r->v.w) {
		real(r->v.dd) = r->v.w;
		imag(r->v.dd) = 0.0;
		goto cdd;
	    }
	flt:
	    l->t = t_float;
	    l->v.d = real(l->v.dd) >= 0.0 ? M_PI_2 : -M_PI_2;
	    break;
	case t_float:
	    if (r->v.d) {
		real(r->v.dd) = r->v.d;
		imag(r->v.dd) = 0.0;
		goto cdd;
	    }
	    goto flt;
	case t_mpz:
	    real(r->v.dd) = mpz_get_d(ozr(r));
	    imag(r->v.dd) = 0.0;
	    goto cdd;
	case t_rat:
	    real(r->v.dd) = rat_get_d(r->v.r);
	    imag(r->v.dd) = 0.0;
	    goto cdd;
	case t_mpq:
	    real(r->v.dd) = mpq_get_d(oqr(r));
	    imag(r->v.dd) = 0.0;
	    goto cdd;
	case t_mpr:
	    mpc_set_fr(occ(r), orr(r), thr_rndc);
	    goto mpc;
	case t_cdd:
	cdd:
	    l->v.dd = catan(l->v.dd / r->v.dd);
	    check_cdd(l);
	    break;
	case t_cqq:
	    real(r->v.dd) = mpq_get_d(oqr(r));
	    imag(r->v.dd) = mpq_get_d(oqi(r));
	    goto cdd;
	case t_mpc:
	mpc:
	    l->t = t_mpc;
	    mpc_set_d_d(occ(l), real(l->v.dd), imag(l->v.dd), thr_rndc);
	    mpc_div(occ(l), occ(l), occ(r), thr_rndc);
	    mpc_atan(occ(l), occ(l), thr_rndc);
	    check_mpc(l);
	    break;
	default:
	    ovm_raise(except_not_a_number);
    }
}
Exemplo n.º 7
0
Arquivo: ovm_mpq.c Projeto: pcpa/owl
void
ovm_q_mul(oregister_t *l, oregister_t *r)
{
    switch (r->t) {
	case t_void:
	    l->t = t_word;
	    l->v.w = 0;
	    break;
	case t_word:
	    mpq_set_si(oqr(r), r->v.w, 1);
	    mpq_mul(oqr(l), oqr(l), oqr(r));
	    check_mpq(l);
	    break;
	case t_float:
	    l->t = t_float;
	    l->v.d = mpq_get_d(oqr(l)) * r->v.d;
	    break;
	case t_mpz:
	    mpz_set_ui(ozs(r), 1);
	    mpq_mul(oqr(l), oqr(l), oqr(r));
	    check_mpq(l);
	    break;
	case t_rat:
	    mpq_set_si(oqr(r), rat_num(r->v.r), rat_den(r->v.r));
	    mpq_mul(oqr(l), oqr(l), oqr(r));
	    check_mpq(l);
	    break;
	case t_mpq:
	    mpq_mul(oqr(l), oqr(l), oqr(r));
	    check_mpq(l);
	    break;
	case t_mpr:
	    l->t = t_mpr;
	    mpfr_set_q(orr(l), oqr(l), thr_rnd);
	    mpfr_mul(orr(l), orr(l), orr(r), thr_rnd);
	    break;
	case t_cdd:
	    l->t = t_cdd;
	    l->v.dd = mpq_get_d(oqr(l)) * r->v.dd;
	    check_cdd(l);
	    break;
	case t_cqq:
	    l->t = t_cqq;
	    mpq_set_ui(oqi(l), 0, 1);
	    cqq_mul(oqq(l), oqq(l), oqq(r));
	    check_cqq(l);
	    break;
	case t_mpc:
	    l->t = t_mpc;
	    mpc_set_q(occ(l), oqr(l), thr_rndc);
	    mpc_mul(occ(l), occ(l), occ(r), thr_rndc);
	    check_mpc(l);
	    break;
	default:
	    ovm_raise(except_not_a_number);
    }
}
Exemplo n.º 8
0
TEST_P(TestSIMNodalConstraint, Face3D)
{
  if (GetParam() > 6)
    return;

  SIMNodalConstraint<SIM3D> s({2});
  std::stringstream str;
  str << "refdata/nodal_3D_F" << GetParam() << ".xinp";
  ASSERT_TRUE(s.read(str.str().c_str()));
  s.preprocess();

  const ASMs3D& pch = static_cast<const ASMs3D&>(*s.getPatch(1));
  int n1, n2, n3;
  pch.getSize(n1,n2,n3);
  for (size_t i=1; i <= pch.getNoNodes(); ++i) {
    if (i % n1 == 1 && GetParam() == 1)
      check_mpc(pch.findMPC(i, 1), n1*n2*n3);
    else if (i % n1 == 0 && GetParam() == 2)
      check_mpc(pch.findMPC(i, 1), 1);
    else if (i % (n1*n2) > 0 && i % (n1*n2) <= (size_t)n1 && GetParam() == 3)
      check_mpc(pch.findMPC(i, 1), n1*n2*n3);
    else if ((i % (n1*n2) >= (size_t)n1*(n2-1)+1 || i % (n1*n2) == 0) && GetParam() == 4)
      check_mpc(pch.findMPC(i, 1), 1);
    else if (i <= (size_t)n1*n2 && GetParam() == 5)
      check_mpc(pch.findMPC(i, 1), n1*n2*n3);
    else if (i >= (size_t)n1*n2*(n3-1)+1 && GetParam() == 6)
      check_mpc(pch.findMPC(i, 1), 1);
    else
      ASSERT_TRUE(pch.findMPC(i, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i, 2) == nullptr);
  }
}
Exemplo n.º 9
0
TEST_P(TestSIMNodalConstraint, Vertex1D)
{
  if (GetParam() > 2)
    return;

  SIMNodalConstraint<SIM1D> s({2});
  std::stringstream str;
  str << "refdata/nodal_1D_V" << GetParam() << ".xinp";
  ASSERT_TRUE(s.read(str.str().c_str()));
  s.preprocess();

  const ASMbase& pch = *s.getPatch(1);
  for (size_t i=1; i <= pch.getNoNodes(); ++i) {
    if (i == 1 && GetParam() == 1)
      check_mpc(pch.findMPC(i,1), pch.getNoNodes());
    else if (i == pch.getNoNodes() && GetParam() == 2)
      check_mpc(pch.findMPC(i,1), 1);
    else
      ASSERT_TRUE(pch.findMPC(i, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i, 2) == nullptr);
  }
}
Exemplo n.º 10
0
TEST(TestSIMNodalConstraint, ASMs3DmxE3)
{
  SIMNodalConstraint<SIM3D> s({2,2});
  ASSERT_TRUE(s.read("refdata/nodal_3D_E3_mixed.xinp"));
  s.preprocess();

  const ASMs3Dmx& pch = static_cast<const ASMs3Dmx&>(*s.getPatch(1));
  int n1, n2, n3;
  pch.getSize(n1,n2,n3,2);
  size_t ofs = pch.getNoNodes(1);
  for (size_t i=1; i <= pch.getNoNodes(1); ++i) {
    ASSERT_TRUE(pch.findMPC(i, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i, 2) == nullptr);
  }
  for (size_t i=1; i <= pch.getNoNodes(2); ++i) {
    if (i >= (size_t)n1*n2*(n3-1)+1 && i <= (size_t)n1*n2*(n3-1)+n1)
      check_mpc(pch.findMPC(i+ofs, 1), 1+ofs);
    else
      ASSERT_TRUE(pch.findMPC(i+ofs, 1) == nullptr);
    ASSERT_TRUE(pch.findMPC(i+ofs, 2) == nullptr);
  }
}
Exemplo n.º 11
0
Arquivo: ovm_mpq.c Projeto: pcpa/owl
void
ovm_q_complex(oregister_t *l, oregister_t *r)
{
    switch (r->t) {
	case t_void:
	    break;
	case t_word:
	    l->t = t_cqq;
	    mpq_set_si(oqi(l), r->v.w, 1);
	    check_cqq(l);
	    break;
	case t_float:
	    l->t = t_cdd;
	    real(l->v.dd) = mpq_get_d(oqr(l));
	    imag(l->v.dd) = r->v.d;
	    check_cdd(l);
	    break;
	case t_mpz:
	    l->t = t_cqq;
	    mpq_set_z(oqi(l), ozr(r));
	    check_cqq(l);
	    break;
	case t_mpq:
	    l->t = t_cqq;
	    mpq_set(oqi(l), oqr(r));
	    check_cqq(l);
	    break;
	case t_mpr:
	    l->t = t_mpc;
	    mpfr_set_q(orr(l), oqr(l), thr_rnd);
	    mpfr_set(ori(l), orr(r), thr_rnd);
	    check_mpc(l);
	    break;
	default:
	    ovm_raise(except_not_a_real_number);
    }
}
Exemplo n.º 12
0
Arquivo: ovm_mpq.c Projeto: pcpa/owl
void
ovm_q_pow(oregister_t *l, oregister_t *r)
{
    switch (r->t) {
	case t_void:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = 1.0;
	    }
	    else {
		l->t = t_mpr;
		mpfr_set_ui(orr(l), 1, thr_rnd);
	    }
	    break;
	case t_word:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = pow(mpq_get_d(oqr(l)), r->v.w);
	    }
	    else {
		mpfr_set_si(orr(r), r->v.w, thr_rnd);
		goto mpr;
	    }
	    break;
	case t_float:
	    if (mpq_sgn(oqr(l)) < 0 &&
		finite(r->v.d) && rint(r->v.d) != r->v.d) {
		real(r->v.dd) = r->v.d;
		imag(r->v.dd) = 0.0;
		goto cdd;
	    }
	    l->t = t_float;
	    l->v.d = pow(mpq_get_d(oqr(l)), r->v.d);
	    break;
	case t_mpz:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = pow(mpq_get_d(oqr(l)), mpz_get_d(ozr(r)));
	    }
	    else {
		mpfr_set_z(orr(r), ozr(r), thr_rnd);
		goto mpr;
	    }
	    break;
	case t_rat:
	    if (mpq_sgn(oqr(l)) < 0) {
		if (!cfg_float_format) {
		    real(r->v.dd) = mpq_get_d(oqr(r));
		    imag(r->v.dd) = 0.0;
		    goto cdd;
		}
		mpc_set_q(occ(r), oqr(r), thr_rndc);
		goto mpc;
	    }
	    else {
		if (!cfg_float_format) {
		    l->t = t_float;
		    l->v.d = pow(mpq_get_d(oqr(l)), rat_get_d(r->v.r));
		}
		else {
		    mpq_set_si(oqr(r), rat_num(r->v.r), rat_den(r->v.r));
		    mpfr_set_q(orr(r), oqr(r), thr_rnd);
		    goto mpr;
		}
	    }
	    break;
	case t_mpq:
	    if (mpq_sgn(oqr(r)) < 0) {
		if (!cfg_float_format) {
		    real(r->v.dd) = mpq_get_d(oqr(r));
		    imag(r->v.dd) = 0.0;
		    goto cdd;
		}
		mpc_set_q(occ(r), oqr(r), thr_rndc);
		goto mpc;
	    }
	    else {
		if (!cfg_float_format) {
		    l->t = t_float;
		    l->v.d = pow(mpq_get_d(oqr(l)), mpq_get_d(oqr(r)));
		}
		else {
		    mpfr_set_q(orr(r), oqr(r), thr_rnd);
		    goto mpr;
		}
	    }
	    break;
	case t_mpr:
	    if (mpq_sgn(oqr(l)) < 0 &&
		mpfr_number_p(orr(r)) && !mpfr_integer_p(orr(r))) {
		mpc_set_q(occ(r), oqr(r), thr_rndc);
		goto mpc;
	    }
	mpr:
	    l->t = t_mpr;
	    mpfr_set_q(orr(l), oqr(l), thr_rnd);
	    mpfr_pow(orr(l), orr(l), orr(r), thr_rnd);
	    break;
	case t_cdd:
	cdd:
	    l->t = t_cdd;
	    real(l->v.dd) = mpq_get_d(oqr(l));
	    imag(l->v.dd) = 0.0;
	    l->v.dd = cpow(l->v.dd, r->v.dd);
	    check_cdd(l);
	    break;
	case t_cqq:
	    if (!cfg_float_format) {
		real(r->v.dd) = mpq_get_d(oqr(r));
		imag(r->v.dd) = mpq_get_d(oqi(r));
		goto cdd;
	    }
	    mpc_set_q_q(occ(r), oqr(r), oqi(r), thr_rndc);
	case t_mpc:
	mpc:
	    l->t = t_mpc;
	    mpc_set_q(occ(l), oqr(l), thr_rndc);
	    mpc_pow(occ(l), occ(l), occ(r), thr_rndc);
	    check_mpc(l);
	    break;
	default:
	    ovm_raise(except_not_a_number);
    }
}
Exemplo n.º 13
0
Arquivo: ovm_mpq.c Projeto: pcpa/owl
void
ovm_q_atan2(oregister_t *l, oregister_t *r)
{
    switch (r->t) {
	case t_void:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = atan2(mpq_get_d(oqr(l)), 0.0);
	    }
	    else {
		mpfr_set_ui(orr(r), 0, thr_rnd);
		goto mpr;
	    }
	    break;
	case t_word:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = atan2(mpq_get_d(oqr(l)), r->v.w);
	    }
	    else {
		mpfr_set_si(orr(r), r->v.w, thr_rnd);
		goto mpr;
	    }
	    break;
	case t_float:
	    l->t = t_float;
	    l->v.d = atan2(mpq_get_d(oqr(l)), r->v.d);
	    break;
	case t_mpz:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = atan2(mpq_get_d(oqr(l)), mpz_get_d(ozr(r)));
	    }
	    else {
		mpfr_set_z(orr(r), ozr(r), thr_rnd);
		goto mpr;
	    }
	    break;
	case t_rat:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = atan2(mpq_get_d(oqr(l)), rat_get_d(r->v.r));
	    }
	    else {
		mpq_set_si(oqr(r), rat_num(r->v.r), rat_den(r->v.r));
		mpfr_set_q(orr(r), oqr(r), thr_rnd);
		goto mpr;
	    }
	    break;
	case t_mpq:
	    if (!cfg_float_format) {
		l->t = t_float;
		l->v.d = atan2(mpq_get_d(oqr(l)), mpq_get_d(oqr(r)));
	    }
	    else {
		mpfr_set_q(orr(r), oqr(r), thr_rnd);
		goto mpr;
	    }
	    break;
	case t_mpr:
	mpr:
	    mpfr_set_q(orr(l), oqr(l), thr_rnd);
	    l->t = t_mpr;
	    mpfr_atan2(orr(l), orr(l), orr(r), thr_rnd);
	    break;
	case t_cdd:
	cdd:
	    l->t = t_cdd;
	    real(l->v.dd) = mpq_get_d(oqr(l));
	    imag(l->v.dd) = 0.0;
	    l->v.dd = catan(l->v.dd / r->v.dd);
	    check_cdd(l);
	    break;
	case t_cqq:
	    if (!cfg_float_format) {
		real(r->v.dd) = mpq_get_d(oqr(r));
		imag(r->v.dd) = mpq_get_d(oqi(r));
		goto cdd;
	    }
	    mpc_set_q_q(occ(r), oqr(r), oqi(r), thr_rndc);
	case t_mpc:
	    l->t = t_mpc;
	    mpc_set_q(occ(l), oqr(l), thr_rndc);
	    mpc_div(occ(l), occ(l), occ(r), thr_rndc);
	    mpc_atan(occ(l), occ(l), thr_rndc);
	    check_mpc(l);
	    break;
	default:
	    ovm_raise(except_not_a_number);
    }
}