void GraphicalUintTest::test_valueString() { GraphicalInt * value = new GraphicalInt(true); value->setValue(Uint(78646)); QCOMPARE( value->valueString(), QString("78646") ); value->setValue(Uint(165464)); QCOMPARE( value->valueString(), QString("165464") ); delete value; }
IterativeSolver::IterativeSolver ( const std::string& name ) : cf3::solver::ActionDirector(name) { mark_basic(); // properties properties().add( "iteration", Uint(0) ); // static components m_pre_actions = create_static_component<ActionDirector>("PreActions"); m_update = create_static_component<ActionDirector>("Update"); m_post_actions = create_static_component<ActionDirector>("PostActions"); // dynamic components create_component<CriterionMaxIterations>( "MaxIterations" ); ComputeLNorm& cnorm = *post_actions().create_component<ComputeLNorm>( "ComputeNorm" ); post_actions().create_component<PrintIterationSummary>( "IterationSummary" ); post_actions().create_component<PeriodicWriteMesh>( "PeriodicWriter" ); cnorm.options().set("scale", true); cnorm.options().set("order", 2u); }
IterativeSolver::IterativeSolver ( const std::string& name ) : CF::Solver::ActionDirector(name) { mark_basic(); // properties m_properties.add_property( "iteration", Uint(0) ); // static components m_pre_actions = create_static_component_ptr<CActionDirector>("PreActions"); m_update = create_static_component_ptr<CActionDirector>("Update"); m_post_actions = create_static_component_ptr<CActionDirector>("PostActions"); // dynamic components create_component<CCriterionMaxIterations>( "MaxIterations" ); CComputeLNorm& cnorm = post_actions().create_component<CComputeLNorm>( "ComputeNorm" ); post_actions().append( cnorm ); CPeriodicWriteMesh& cwriter = post_actions().create_component<CPeriodicWriteMesh>( "PeriodicWriter" ); post_actions().append( cwriter ); cnorm.configure_option("Scale", true); cnorm.configure_option("Order", 2u); }
boost::optional<Block> JsonBlockFactory::deserialize( const Document &document) { auto des = makeFieldDeserializer(document); auto des_transactions = [this](auto array) { auto acc_transactions = [this](auto init, auto &x) { return init | [this, &x](auto transactions) { return factory_.deserialize(x) | [&transactions](auto transaction) { transactions.push_back(transaction); return boost::make_optional(std::move(transactions)); }; }; }; return std::accumulate( array.begin(), array.end(), boost::make_optional(Block::TransactionsType()), acc_transactions); }; return boost::make_optional(model::Block()) | des.Uint64(&Block::created_ts, "created_ts") | des.Uint64(&Block::height, "height") | des.Uint(&Block::txs_number, "txs_number") | des.String(&Block::hash, "hash") | des.String(&Block::prev_hash, "prev_hash") | des.Array(&Block::sigs, "signatures") | des.Array(&Block::transactions, "transactions", des_transactions); }
Implementation(Action& timed_action) : m_timed_component(timed_action) { m_timed_component.properties().add("timer_count", Uint(0)); m_timed_component.properties().add("timer_minimum", Real(0.)); m_timed_component.properties().add("timer_mean", Real(0.)); m_timed_component.properties().add("timer_maximum", Real(0.)); m_timed_component.properties().add("timer_variance", Real(0.)); }
Real ComputeUpdateCoefficient::limit_end_time(const Real& time, const Real& end_time) { const Real milestone_dt = m_time->options().value<Real>("time_step"); if (milestone_dt == 0) return end_time; const Real milestone_time = (Uint((time+m_tolerance)/milestone_dt)+1.)*milestone_dt; return std::min(milestone_time,end_time); }
void GraphicalUintTest::test_constructor() { GraphicalInt * value = new GraphicalInt(true); QDoubleSpinBox * spinBox = findSpinBox(value); QVERIFY( is_not_null(spinBox) ); // 1. check the range QCOMPARE( Uint(spinBox->minimum()), Consts::uint_min() ); QCOMPARE( Uint(spinBox->maximum()), Consts::uint_max() ); // 2. value is empty, the line edit should be empty as well QCOMPARE( int(spinBox->value()), 0 ); delete value; value = new GraphicalInt(true, 1456); spinBox = findSpinBox(value); // 3. value is not empty QVERIFY( is_not_null(spinBox) ); QCOMPARE( int(spinBox->value()), 1456 ); delete value; }
void GraphicalUintTest::test_signalEmmitting() { GraphicalInt * value = new GraphicalInt(true); QDoubleSpinBox * spinBox = findSpinBox(value); QSignalSpy spy(value, SIGNAL(valueChanged())); // // 1. through setValue() // value->setValue(Uint(125464)); value->setValue(-876541); // 1 signals should have been emitted (the second value is not a Uint) QCOMPARE( spy.count(), 1 ); spy.clear(); // // 2. by simulating keyboard events // spinBox->clear(); value->show(); // make the value visible (it ignores keyboard events if not) QTest::keyClicks(spinBox, "+2014" ); QTest::keyClicks(spinBox, "357" ); QTest::keyClicks(spinBox, "aq45s2" ); // 10 signals should have been emitted (one per character) // (13 chars entered but '-', 'a', 'q' and 's' were ignored) QCOMPARE( spy.count(), 10 ); spy.clear(); // // 3. when committing // value->commit(); // 1 signal should have been emitted QCOMPARE( spy.count(), 1 ); delete value; }
void create_circle_2d ( Mesh& mesh, const Real radius, const Uint segments, const Real start_angle, const Real end_angle ) { Region& region = mesh.topology().create_region("region"); Dictionary& nodes = mesh.geometry_fields(); Handle<Faces> cells = region.create_component<Faces>("Faces"); cells->initialize("cf3.mesh.LagrangeP1.Line2D",nodes); cells->resize(segments); Table<Uint>& connectivity = cells->geometry_space().connectivity(); const bool closed = std::abs(std::abs(end_angle - start_angle) - 2.0*pi()) < eps(); mesh.initialize_nodes(segments + Uint(!closed) , DIM_2D); for(Uint u = 0; u != segments; ++u) { const Real theta = start_angle + (end_angle - start_angle) * (static_cast<Real>(u) / static_cast<Real>(segments)); Table<Real>::Row coord_row = nodes.coordinates()[u]; coord_row[XX] = radius * cos(theta); coord_row[YY] = radius * sin(theta); Table<Uint>::Row nodes = connectivity[u]; nodes[0] = u; nodes[1] = u+1; } if(closed) { connectivity[segments-1][1] = 0; } else { Table<Real>::Row coord_row = nodes.coordinates()[segments]; coord_row[XX] = radius * cos(end_angle); coord_row[YY] = radius * sin(end_angle); } build_serial_gids(mesh); mesh.raise_mesh_loaded(); }
void CField::create_data_storage() { cf_assert( m_var_types.size()!=0 ); cf_assert( is_not_null(m_topology->follow()) ); // Check if there are coordinates in this field, and add to map m_coords = find_parent_component<CMesh>(topology()).nodes().coordinates().as_ptr<CTable<Real> >(); Uint row_size(0); boost_foreach(const VarType var_size, m_var_types) row_size += Uint(var_size); m_data->set_row_size(row_size); switch (m_basis) { case Basis::POINT_BASED: { m_used_nodes = CElements::used_nodes(topology()).as_ptr<CList<Uint> >(); m_data->resize(m_used_nodes->size()); break; } case Basis::ELEMENT_BASED: { Uint data_size = 0; boost_foreach(CEntities& field_elements, find_components_recursively<CEntities>(topology())) { if (field_elements.exists_space(m_space_name) == false) throw ValueNotFound(FromHere(),"space \""+m_space_name+"\" does not exist in "+field_elements.uri().path()); m_elements_start_idx[field_elements.as_ptr<CEntities>()] = data_size; CFieldView field_view("tmp_field_view"); data_size = field_view.initialize(*this,field_elements.as_ptr<CEntities>()); } m_data->resize(data_size); break; } case Basis::CELL_BASED: { Uint data_size = 0; boost_foreach(CEntities& field_elements, find_components_recursively<CCells>(topology())) { //CFinfo << name() << ": creating cellbased field storage in " << field_elements.uri().path() << CFendl; if (field_elements.exists_space(m_space_name) == false) throw ValueNotFound(FromHere(),"space \""+m_space_name+"\" does not exist in "+field_elements.uri().path()); m_elements_start_idx[field_elements.as_ptr<CEntities>()] = data_size; CFieldView field_view("tmp_field_view"); data_size = field_view.initialize(*this,field_elements.as_ptr<CEntities>()); } m_data->resize(data_size); break; } case Basis::FACE_BASED: { Uint data_size = 0; boost_foreach(CEntities& field_elements, find_components_recursively_with_tag<CEntities>(topology(),Mesh::Tags::face_entity())) { if (field_elements.exists_space(m_space_name) == false) throw ValueNotFound(FromHere(),"space \""+m_space_name+"\" does not exist in "+field_elements.uri().path()); m_elements_start_idx[field_elements.as_ptr<CEntities>()] = data_size; CFieldView field_view("tmp_field_view"); data_size = field_view.initialize(*this,field_elements.as_ptr<CEntities>()); } m_data->resize(data_size); break; } default: throw NotSupported(FromHere() , "Basis can only be ELEMENT_BASED or NODE_BASED"); break; } }
void GraphicalUintTest::test_setValue() { GraphicalInt * value = new GraphicalInt(true); QDoubleSpinBox * spinBox = findSpinBox(value); QVERIFY( is_not_null(spinBox) ); // // 1. check with Uints // QVERIFY( value->setValue(Uint(1456)) ); QCOMPARE( Uint(spinBox->value()), Uint(1456) ); QVERIFY( value->setValue(Uint(215468)) ); QCOMPARE( Uint(spinBox->value()), Uint(215468) ); // // 2. check with other types // QVERIFY( !value->setValue(-3592) ); QCOMPARE( Uint(spinBox->value()), Uint(215468) ); QVERIFY( !value->setValue(3.141592) ); QCOMPARE( Uint(spinBox->value()), Uint(215468) ); QVERIFY( !value->setValue(true) ); QCOMPARE( Uint(spinBox->value()), Uint(215468) ); QVERIFY( !value->setValue("789654123") ); QCOMPARE( Uint(spinBox->value()), Uint(215468) ); delete value; }
void InitialCondition::compute() { // -- NOTE ---- // The following code is a copy from libMesh project_vector.C plus it adds some features, so we can couple variable values // and we also do not call any callbacks, but we use our initial condition system directly. // ------------ // The element matrix and RHS for projections. // Note that Ke is always real-valued, whereas Fe may be complex valued if complex number support is enabled DenseMatrix<Real> Ke; DenseVector<Number> Fe; // The new element coefficients DenseVector<Number> Ue; const FEType & fe_type = _var.feType(); // The dimension of the current element const unsigned int dim = _current_elem->dim(); // The element type const ElemType elem_type = _current_elem->type(); // The number of nodes on the new element const unsigned int n_nodes = _current_elem->n_nodes(); // The global DOF indices std::vector<dof_id_type> dof_indices; // Side/edge DOF indices std::vector<unsigned int> side_dofs; // Get FE objects of the appropriate type // We cannot use the FE object in Assembly, since the following code is messing with the quadrature rules // for projections and would screw it up. However, if we implement projections from one mesh to another, // this code should use that implementation. UniquePtr<FEBase> fe (FEBase::build(dim, fe_type)); // Prepare variables for projection UniquePtr<QBase> qrule (fe_type.default_quadrature_rule(dim)); UniquePtr<QBase> qedgerule (fe_type.default_quadrature_rule(1)); UniquePtr<QBase> qsiderule (fe_type.default_quadrature_rule(dim-1)); // The values of the shape functions at the quadrature points const std::vector<std::vector<Real> > & phi = fe->get_phi(); // The gradients of the shape functions at the quadrature points on the child element. const std::vector<std::vector<RealGradient> > * dphi = NULL; const FEContinuity cont = fe->get_continuity(); if (cont == C_ONE) { const std::vector<std::vector<RealGradient> > & ref_dphi = fe->get_dphi(); dphi = &ref_dphi; } // The Jacobian * quadrature weight at the quadrature points const std::vector<Real> & JxW = fe->get_JxW(); // The XYZ locations of the quadrature points const std::vector<Point>& xyz_values = fe->get_xyz(); // Update the DOF indices for this element based on the current mesh _var.prepareIC(); dof_indices = _var.dofIndices(); // The number of DOFs on the element const unsigned int n_dofs = dof_indices.size(); if (n_dofs == 0) return; // Fixed vs. free DoFs on edge/face projections std::vector<char> dof_is_fixed(n_dofs, false); // bools std::vector<int> free_dof(n_dofs, 0); // Zero the interpolated values Ue.resize (n_dofs); Ue.zero(); // In general, we need a series of // projections to ensure a unique and continuous // solution. We start by interpolating nodes, then // hold those fixed and project edges, then // hold those fixed and project faces, then // hold those fixed and project interiors _fe_problem.sizeZeroes(n_nodes, _tid); // Interpolate node values first unsigned int current_dof = 0; for (unsigned int n = 0; n != n_nodes; ++n) { // FIXME: this should go through the DofMap, // not duplicate dof_indices code badly! const unsigned int nc = FEInterface::n_dofs_at_node (dim, fe_type, elem_type, n); if (!_current_elem->is_vertex(n)) { current_dof += nc; continue; } if (cont == DISCONTINUOUS) { libmesh_assert(nc == 0); } // Assume that C_ZERO elements have a single nodal // value shape function else if (cont == C_ZERO) { libmesh_assert(nc == 1); _qp = n; _current_node = _current_elem->get_node(n); Ue(current_dof) = value(*_current_node); dof_is_fixed[current_dof] = true; current_dof++; } // The hermite element vertex shape functions are weird else if (fe_type.family == HERMITE) { _qp = n; _current_node = _current_elem->get_node(n); Ue(current_dof) = value(*_current_node); dof_is_fixed[current_dof] = true; current_dof++; Gradient grad = gradient(*_current_node); // x derivative Ue(current_dof) = grad(0); dof_is_fixed[current_dof] = true; current_dof++; if (dim > 1) { // We'll finite difference mixed derivatives Point nxminus = _current_elem->point(n), nxplus = _current_elem->point(n); nxminus(0) -= TOLERANCE; nxplus(0) += TOLERANCE; Gradient gxminus = gradient(nxminus); Gradient gxplus = gradient(nxplus); // y derivative Ue(current_dof) = grad(1); dof_is_fixed[current_dof] = true; current_dof++; // xy derivative Ue(current_dof) = (gxplus(1) - gxminus(1)) / 2. / TOLERANCE; dof_is_fixed[current_dof] = true; current_dof++; if (dim > 2) { // z derivative Ue(current_dof) = grad(2); dof_is_fixed[current_dof] = true; current_dof++; // xz derivative Ue(current_dof) = (gxplus(2) - gxminus(2)) / 2. / TOLERANCE; dof_is_fixed[current_dof] = true; current_dof++; // We need new points for yz Point nyminus = _current_elem->point(n), nyplus = _current_elem->point(n); nyminus(1) -= TOLERANCE; nyplus(1) += TOLERANCE; Gradient gyminus = gradient(nyminus); Gradient gyplus = gradient(nyplus); // xz derivative Ue(current_dof) = (gyplus(2) - gyminus(2)) / 2. / TOLERANCE; dof_is_fixed[current_dof] = true; current_dof++; // Getting a 2nd order xyz is more tedious Point nxmym = _current_elem->point(n), nxmyp = _current_elem->point(n), nxpym = _current_elem->point(n), nxpyp = _current_elem->point(n); nxmym(0) -= TOLERANCE; nxmym(1) -= TOLERANCE; nxmyp(0) -= TOLERANCE; nxmyp(1) += TOLERANCE; nxpym(0) += TOLERANCE; nxpym(1) -= TOLERANCE; nxpyp(0) += TOLERANCE; nxpyp(1) += TOLERANCE; Gradient gxmym = gradient(nxmym); Gradient gxmyp = gradient(nxmyp); Gradient gxpym = gradient(nxpym); Gradient gxpyp = gradient(nxpyp); Number gxzplus = (gxpyp(2) - gxmyp(2)) / 2. / TOLERANCE; Number gxzminus = (gxpym(2) - gxmym(2)) / 2. / TOLERANCE; // xyz derivative Ue(current_dof) = (gxzplus - gxzminus) / 2. / TOLERANCE; dof_is_fixed[current_dof] = true; current_dof++; } } } // Assume that other C_ONE elements have a single nodal // value shape function and nodal gradient component // shape functions else if (cont == C_ONE) { libmesh_assert(nc == 1 + dim); _current_node = _current_elem->get_node(n); Ue(current_dof) = value(*_current_node); dof_is_fixed[current_dof] = true; current_dof++; Gradient grad = gradient(*_current_node); for (unsigned int i=0; i != dim; ++i) { Ue(current_dof) = grad(i); dof_is_fixed[current_dof] = true; current_dof++; } } else libmesh_error(); } // loop over nodes // From here on out we won't be sampling at nodes anymore _current_node = NULL; // In 3D, project any edge values next if (dim > 2 && cont != DISCONTINUOUS) for (unsigned int e=0; e != _current_elem->n_edges(); ++e) { FEInterface::dofs_on_edge(_current_elem, dim, fe_type, e, side_dofs); // Some edge dofs are on nodes and already // fixed, others are free to calculate unsigned int free_dofs = 0; for (unsigned int i=0; i != side_dofs.size(); ++i) if (!dof_is_fixed[side_dofs[i]]) free_dof[free_dofs++] = i; // There may be nothing to project if (!free_dofs) continue; Ke.resize (free_dofs, free_dofs); Ke.zero(); Fe.resize (free_dofs); Fe.zero(); // The new edge coefficients DenseVector<Number> Uedge(free_dofs); // Initialize FE data on the edge fe->attach_quadrature_rule (qedgerule.get()); fe->edge_reinit (_current_elem, e); const unsigned int n_qp = qedgerule->n_points(); _fe_problem.sizeZeroes(n_qp, _tid); // Loop over the quadrature points for (unsigned int qp = 0; qp < n_qp; qp++) { // solution at the quadrature point Number fineval = value(xyz_values[qp]); // solution grad at the quadrature point Gradient finegrad; if (cont == C_ONE) finegrad = gradient(xyz_values[qp]); // Form edge projection matrix for (unsigned int sidei = 0, freei = 0; sidei != side_dofs.size(); ++sidei) { unsigned int i = side_dofs[sidei]; // fixed DoFs aren't test functions if (dof_is_fixed[i]) continue; for (unsigned int sidej = 0, freej = 0; sidej != side_dofs.size(); ++sidej) { unsigned int j = side_dofs[sidej]; if (dof_is_fixed[j]) Fe(freei) -= phi[i][qp] * phi[j][qp] * JxW[qp] * Ue(j); else Ke(freei,freej) += phi[i][qp] * phi[j][qp] * JxW[qp]; if (cont == C_ONE) { if (dof_is_fixed[j]) Fe(freei) -= ((*dphi)[i][qp] * (*dphi)[j][qp]) * JxW[qp] * Ue(j); else Ke(freei,freej) += ((*dphi)[i][qp] * (*dphi)[j][qp]) * JxW[qp]; } if (!dof_is_fixed[j]) freej++; } Fe(freei) += phi[i][qp] * fineval * JxW[qp]; if (cont == C_ONE) Fe(freei) += (finegrad * (*dphi)[i][qp]) * JxW[qp]; freei++; } } Ke.cholesky_solve(Fe, Uedge); // Transfer new edge solutions to element for (unsigned int i=0; i != free_dofs; ++i) { Number &ui = Ue(side_dofs[free_dof[i]]); libmesh_assert(std::abs(ui) < TOLERANCE || std::abs(ui - Uedge(i)) < TOLERANCE); ui = Uedge(i); dof_is_fixed[side_dofs[free_dof[i]]] = true; } } // Project any side values (edges in 2D, faces in 3D) if (dim > 1 && cont != DISCONTINUOUS) for (unsigned int s=0; s != _current_elem->n_sides(); ++s) { FEInterface::dofs_on_side(_current_elem, dim, fe_type, s, side_dofs); // Some side dofs are on nodes/edges and already // fixed, others are free to calculate unsigned int free_dofs = 0; for (unsigned int i=0; i != side_dofs.size(); ++i) if (!dof_is_fixed[side_dofs[i]]) free_dof[free_dofs++] = i; // There may be nothing to project if (!free_dofs) continue; Ke.resize (free_dofs, free_dofs); Ke.zero(); Fe.resize (free_dofs); Fe.zero(); // The new side coefficients DenseVector<Number> Uside(free_dofs); // Initialize FE data on the side fe->attach_quadrature_rule (qsiderule.get()); fe->reinit (_current_elem, s); const unsigned int n_qp = qsiderule->n_points(); _fe_problem.sizeZeroes(n_qp, _tid); // Loop over the quadrature points for (unsigned int qp = 0; qp < n_qp; qp++) { // solution at the quadrature point Number fineval = value(xyz_values[qp]); // solution grad at the quadrature point Gradient finegrad; if (cont == C_ONE) finegrad = gradient(xyz_values[qp]); // Form side projection matrix for (unsigned int sidei = 0, freei = 0; sidei != side_dofs.size(); ++sidei) { unsigned int i = side_dofs[sidei]; // fixed DoFs aren't test functions if (dof_is_fixed[i]) continue; for (unsigned int sidej = 0, freej = 0; sidej != side_dofs.size(); ++sidej) { unsigned int j = side_dofs[sidej]; if (dof_is_fixed[j]) Fe(freei) -= phi[i][qp] * phi[j][qp] * JxW[qp] * Ue(j); else Ke(freei,freej) += phi[i][qp] * phi[j][qp] * JxW[qp]; if (cont == C_ONE) { if (dof_is_fixed[j]) Fe(freei) -= ((*dphi)[i][qp] * (*dphi)[j][qp]) * JxW[qp] * Ue(j); else Ke(freei,freej) += ((*dphi)[i][qp] * (*dphi)[j][qp]) * JxW[qp]; } if (!dof_is_fixed[j]) freej++; } Fe(freei) += (fineval * phi[i][qp]) * JxW[qp]; if (cont == C_ONE) Fe(freei) += (finegrad * (*dphi)[i][qp]) * JxW[qp]; freei++; } } Ke.cholesky_solve(Fe, Uside); // Transfer new side solutions to element for (unsigned int i=0; i != free_dofs; ++i) { Number &ui = Ue(side_dofs[free_dof[i]]); libmesh_assert(std::abs(ui) < TOLERANCE || std::abs(ui - Uside(i)) < TOLERANCE); ui = Uside(i); dof_is_fixed[side_dofs[free_dof[i]]] = true; } } // Project the interior values, finally // Some interior dofs are on nodes/edges/sides and // already fixed, others are free to calculate unsigned int free_dofs = 0; for (unsigned int i=0; i != n_dofs; ++i) if (!dof_is_fixed[i]) free_dof[free_dofs++] = i; // There may be nothing to project if (free_dofs) { Ke.resize (free_dofs, free_dofs); Ke.zero(); Fe.resize (free_dofs); Fe.zero(); // The new interior coefficients DenseVector<Number> Uint(free_dofs); // Initialize FE data fe->attach_quadrature_rule (qrule.get()); fe->reinit (_current_elem); const unsigned int n_qp = qrule->n_points(); _fe_problem.sizeZeroes(n_qp, _tid); // Loop over the quadrature points for (unsigned int qp=0; qp<n_qp; qp++) { // solution at the quadrature point Number fineval = value(xyz_values[qp]); // solution grad at the quadrature point Gradient finegrad; if (cont == C_ONE) finegrad = gradient(xyz_values[qp]); // Form interior projection matrix for (unsigned int i=0, freei=0; i != n_dofs; ++i) { // fixed DoFs aren't test functions if (dof_is_fixed[i]) continue; for (unsigned int j=0, freej=0; j != n_dofs; ++j) { if (dof_is_fixed[j]) Fe(freei) -= phi[i][qp] * phi[j][qp] * JxW[qp] * Ue(j); else Ke(freei,freej) += phi[i][qp] * phi[j][qp] * JxW[qp]; if (cont == C_ONE) { if (dof_is_fixed[j]) Fe(freei) -= ((*dphi)[i][qp] * (*dphi)[j][qp]) * JxW[qp] * Ue(j); else Ke(freei,freej) += ((*dphi)[i][qp] * (*dphi)[j][qp]) * JxW[qp]; } if (!dof_is_fixed[j]) freej++; } Fe(freei) += phi[i][qp] * fineval * JxW[qp]; if (cont == C_ONE) Fe(freei) += (finegrad * (*dphi)[i][qp]) * JxW[qp]; freei++; } } Ke.cholesky_solve(Fe, Uint); // Transfer new interior solutions to element for (unsigned int i=0; i != free_dofs; ++i) { Number &ui = Ue(free_dof[i]); libmesh_assert(std::abs(ui) < TOLERANCE || std::abs(ui - Uint(i)) < TOLERANCE); ui = Uint(i); dof_is_fixed[free_dof[i]] = true; } } // if there are free interior dofs // Make sure every DoF got reached! for (unsigned int i=0; i != n_dofs; ++i) libmesh_assert(dof_is_fixed[i]); NumericVector<Number> & solution = _var.sys().solution(); // 'first' and 'last' are no longer used, see note about subdomain-restricted variables below // const dof_id_type // first = solution.first_local_index(), // last = solution.last_local_index(); // Lock the new_vector since it is shared among threads. { Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); for (unsigned int i = 0; i < n_dofs; i++) // We may be projecting a new zero value onto // an old nonzero approximation - RHS // if (Ue(i) != 0.) // This is commented out because of subdomain restricted variables. // It can be the case that if a subdomain restricted variable's boundary // aligns perfectly with a processor boundary that the variable will get // no value. To counteract this we're going to let every processor set a // value at every node and then let PETSc figure it out. // Later we can choose to do something different / better. // if ((dof_indices[i] >= first) && (dof_indices[i] < last)) { solution.set(dof_indices[i], Ue(i)); if (cont == C_ZERO) _var.setNodalValue(Ue(i), i); } } }
virtual void init() { float const width = (float) CoreEngine::instance()->mainWindow()->contextOptions().width; float const height = (float) CoreEngine::instance()->mainWindow()->contextOptions().height; CoreEngine::instance()->renderEngine().setViewport(0, 0, width, height); video_capture = VideoCapture::create(); if (true) { SharedPointer<ThreadedVideoCapture> threaded_video_capture = new ThreadedVideoCapture(video_capture); video_capture = threaded_video_capture; } VideoCapture::Devices devices = video_capture->enumerateDevices(); for (Uint index = 0; index != Uint(devices.size()); ++index) { CoreEngine::instance()->log() << "--- Capture Device [" << devices[index].index << "] ---" << std::endl; CoreEngine::instance()->log() << "Location \t" << devices[index].location << std::endl; CoreEngine::instance()->log() << "Name \t\t" << devices[index].name << std::endl; CoreEngine::instance()->log() << "Driver \t\t" << devices[index].driver << std::endl; CoreEngine::instance()->log() << "Bus \t\t" << devices[index].bus << std::endl; VideoCapture::Format format; //format.mode = "YUY2"; //format.mode = "YUYV"; //format.mode = "MJPG"; format.interval_denominator = 5; //format.width = 320; //format.height = 120; VideoCapture::Formats formats = video_capture->enumerateFormats(devices[index]); formats = VideoCapture::filterByFormat( video_capture->enumerateFormats(devices[index]) , format); format = VideoCapture::matchBestFormat( video_capture->enumerateFormats(devices[index]) , format); CoreEngine::instance()->log() << "[B] \t" << format.mode << " \t" << format.width << "x" << format.height << " \t" << format.interval_numerator << " / " << format.interval_denominator << std::endl; for (Uint format_index = 0; format_index != Uint(formats.size()); ++format_index) { format = formats[format_index]; CoreEngine::instance()->log() << "[" << format_index << "] \t" << format.mode << " \t" << format.width << "x" << format.height << " \t" << format.interval_numerator << " / " << format.interval_denominator << std::endl; } } VideoCapture::CaptureOptions options; //options.mode = "MJPG"; //options.mode = "YUY2"; //options.mode = "RGB3"; //options.width = 640; //options.interval_denominator = 5; try { video_capture->open(options); } catch (VideoCaptureException caught) { cout << caught << endl; } if (video_capture->ready()) { SharedPointer<Image> image = new Image(video_capture->captureOptions().width, video_capture->captureOptions().height, 3); image->zeroImage(); texture = new Texture2D(image); quadrilateral = new Quadrilateral(); quadrilateral->setCornersVertex(Vector3D(0.0f, 0.0f, 0.0f), Vector3D(Real(video_capture->captureOptions().width), Real(video_capture->captureOptions().height), 0.0f)); quadrilateral->states()->setTexture(texture); SharedPointer<Program> decal_program = CoreEngine::instance()->resourceManager().load<Program>("data/shaders/core/DecalTexture.eff"); quadrilateral->states()->setCapability(DrawStates::DepthTest, DrawStates::Off); quadrilateral->states()->setCapability(DrawStates::Blend, DrawStates::Off); quadrilateral->states()->setCapability(DrawStates::CullFace, DrawStates::Off); quadrilateral->states()->setProgram(decal_program); } }
/** * * loop momentums,propagator expressions, * invariants substitutions,propagator powers,number of loops * \param k_lst loop momentums list \param p_lst propagator expressions list \param subs_lst invariants substitutions list \param nu propagator powers list \param l number of loops \return * */ RoMB_loop_by_loop:: RoMB_loop_by_loop( lst k_lst, lst p_lst, lst subs_lst, lst nu, bool subs_U ) { try { /* empty integral */ MBintegral MBlbl_int(lst(),lst(),1); /* Full set of unused propagators, will change */ exlist input_prop_set;//( p_lst.begin(),p_lst.end()); /* map for propagator powers */ exmap prop_pow_map; for(lst::const_iterator Pit = p_lst.begin(); Pit != p_lst.end(); ++Pit) { input_prop_set.push_back(Pit->expand()); prop_pow_map[Pit->expand()] = nu.op(std::distance(p_lst.begin(),Pit)); } cout<<"INPSET: "<<input_prop_set<<endl; /* Iterate over momentums k1,k2,k3,etc. */ unsigned int displacement_x = 0; unsigned int displacement_w = 0; for(lst::const_iterator kit = k_lst.begin(); kit != k_lst.end(); ++kit) { // Integral Normalization coefficient // MBlbl_int *= pow(I,k_lst.nops()); MBlbl_int *= 1/tgamma(1+get_symbol("eps")); //MBlbl_int *= pow(Pi,2-get_symbol("eps")); //MBlbl_int *= exp(Euler*get_symbol("eps")); cout<<"PROP_POW_MAP "<<prop_pow_map<<endl; /* temporary set of propagators, with all momentum,except deleted */ exlist tmp_p_lst(input_prop_set.begin(), input_prop_set.end()); /* temporary set of propagators, with KIT momentum */ lst P_with_k_lst; BOOST_FOREACH(ex prop_tmp, tmp_p_lst) { if(prop_tmp.has(*kit)) { P_with_k_lst.append(prop_tmp); input_prop_set.remove(prop_tmp); } } cout<< "Set wo k_i "<<input_prop_set<<endl; cout<<" PWKlst "<<P_with_k_lst<<endl; bool direct_formula_applied = false; // if only one term in PWKLST use well known formulas // [Smirnov A.1] if(!direct_formula_applied && (P_with_k_lst.nops() == 1)) { ex pr_t = P_with_k_lst.op(0); ex nu_t = prop_pow_map[pr_t]; exmap repls; BOOST_ASSERT_MSG(pr_t.match(-pow(*kit,2) + wild(2)),"ONE PROP"); if(pr_t.match(-pow(*kit,2) + wild(2),repls))cout<<"repls: "<<repls<<endl; ex mass_tadpole = (tgamma(nu_t+get_symbol("eps")-2)/tgamma(nu_t)*pow(wild(2).subs(repls),-nu_t-get_symbol("eps")+2)); cout<<mass_tadpole<<endl; MBlbl_int *= mass_tadpole; MBlbl_int.add_pole(nu_t+get_symbol("eps")-2); direct_formula_applied = true; } if(!direct_formula_applied && (P_with_k_lst.nops() == 2)) { //TWO terms in PWK_LST, [Smirnov A.4] exmap repls_tad; if((P_with_k_lst.nops()==2) && (( (P_with_k_lst.op(0).match(-pow(*kit,2))) && (P_with_k_lst.op(1).match(-pow(*kit,2)+wild())))|| ( (P_with_k_lst.op(1).match(-pow(*kit,2))) && (P_with_k_lst.op(0).match(-pow(*kit,2)+wild())))) && !wild().has(*kit) ) { cout<<"Two prop tadpole "<<wild()<<endl; exmap r1,r2; ex mm,lmb1,lmb2; if( (P_with_k_lst.op(0).match(-pow(*kit,2))) && (P_with_k_lst.op(1).match(-pow(*kit,2)+wild(),r1))) { lmb1 = prop_pow_map[P_with_k_lst.op(1)]; lmb2 = prop_pow_map[P_with_k_lst.op(0)]; mm=wild().subs(r1); } else if( (P_with_k_lst.op(1).match(-pow(*kit,2))) && (P_with_k_lst.op(0).match(-pow(*kit,2)+wild(),r2))) { lmb1 = prop_pow_map[P_with_k_lst.op(0)]; lmb2 = prop_pow_map[P_with_k_lst.op(1)]; mm=wild().subs(r2); } else throw std::logic_error(std::string("Wrong two prop topology to use eq [Smir:A.4]")); ex mass_tadpole = tgamma(lmb1+lmb2+get_symbol("eps")-2)*tgamma(-lmb2-get_symbol("eps")+2)/tgamma(lmb1)/tgamma(2-get_symbol("eps"))*pow(mm,-lmb1-lmb2-get_symbol("eps")+2); cout<<mass_tadpole<<endl; } } if(!direct_formula_applied) { // cout<< " coe: "<<coe_prop_lst<<endl; /* lexi sort of input prop list, and it's modification */ // uf and then MB represenatation construction // subs only in F for last momentum UFXmap inUFmap; if(boost::next(kit) == k_lst.end()) inUFmap = UF(lst(*kit),P_with_k_lst,subs_lst,displacement_x); else inUFmap = UF(lst(*kit),P_with_k_lst,subs_lst,displacement_x); // no substitution!!! displacement_x +=fusion::at_key<UFX::xlst>(inUFmap).nops(); lst nu_into; for(lst::const_iterator nuit = P_with_k_lst.begin(); nuit != P_with_k_lst.end(); ++nuit ) nu_into.append(prop_pow_map[*nuit]); cout<<" Powers list before input: "<<nu_into<<endl; /* MBintegral Uint( fusion::make_map<UFX::F,UFX::xlst>(fusion::at_key<UFX::F>(inUFmap), fusion::at_key<UFX::xlst>(inUFmap) ),nu_into,1,displacement_w); */ MBintegral Uint(inUFmap,nu_into,1,subs_U,displacement_w); displacement_w+=Uint.w_size(); cout<<"ui9nt eps (no gamma) : "<<Uint.get_expr().subs(tgamma(wild()) == 1)<<endl; cout<<"ui9nt eps : "<<Uint.get_expr()<<endl; /* expression to mul root integral where to subs prop(k_prev)==1 */ ex expr_k_to_subs_1= Uint.get_expr(); ex mom_find = Uint.get_expr(); cout<< "where find props: "<<mom_find<<endl; if(is_a<mul>(mom_find)) { // set of a^b?, need to have momentums from *kit to *k_lst.end() exset found_prop_raw,found_prop; mom_find.find(pow(wild(1),wild(2)),found_prop_raw); cout<<" is a mul raw "<<found_prop_raw<<endl; // really props BOOST_FOREACH(ex px_c,found_prop_raw) { bool is_a_p = false; for(lst::const_iterator kpi = kit; kpi != k_lst.end(); ++kpi) if(px_c.has(*kpi)) { is_a_p = true; break; } if(is_a_p) found_prop.insert(px_c); } cout<<" is a mul "<<found_prop<<endl; BOOST_FOREACH(ex propex_c,found_prop) { // next momentum in loop momentum list ex next_k ; for(lst::const_iterator nkit = kit; nkit != k_lst.end(); ++nkit) if(propex_c.has(*nkit)) { next_k = *nkit; break; } cout<<"before subs kex : "<<expr_k_to_subs_1.subs(tgamma(wild()) == 1)<<endl; expr_k_to_subs_1 = expr_k_to_subs_1.subs(propex_c == 1); cout<<"after subs kex : "<<expr_k_to_subs_1.subs(tgamma(wild()) == 1)<<endl; /* converting prop to form -p^2+m^2 */ ex p_power; ex p_expr; ex p_not_corr = ex_to<power>(propex_c).op(0); ex coeff_ksq = p_not_corr.expand().coeff(next_k,2); // coeff infront of K^2 if( coeff_ksq != -1 ) { p_not_corr /=coeff_ksq; cout<<"koeff_ksq "<<coeff_ksq<<endl; MBlbl_int*= pow(coeff_ksq,ex_to<power>(propex_c).op(1)); // propex = pow(p_not_corr,ex_to<power>(propex_c).op(1)); p_power = ex_to<power>(propex_c).op(1); p_expr = p_not_corr.expand(); } else { p_power = ex_to<power>(propex_c).op(1); p_expr = ex_to<power>(propex_c).op(0).expand(); } /* Search for duplications in prop set */ cout<<"where to find props: "<<input_prop_set<<endl; cout<< input_prop_set.size()<<endl; cout<<"PWK_MAP to modiff"<<prop_pow_map<<endl; if(prop_pow_map.count(p_expr) > 0) { BOOST_ASSERT_MSG(count(input_prop_set.begin(),input_prop_set.end(),p_expr) > 0,"Propagator not found in prop set"); cout<<"PPM bef: "<< prop_pow_map[p_expr]<<endl; prop_pow_map[p_expr] -=p_power; cout<<"PPM aft: "<< prop_pow_map[p_expr]<<endl; } else { prop_pow_map[p_expr] = (-1)*p_power; input_prop_set.push_back(p_expr); } cout<<"PWK_MAP after modiff"<<prop_pow_map<<endl; } } //cout<<"needed props "<<prop_pow_lst<<endl; cout<<"ya tut"<<endl; MBlbl_int*=expr_k_to_subs_1; cout<<"ya tut"<<endl; // cout<<"HAS INT : "<<MBlbl_int.get_expr().subs(tgamma(wild(4)) == 0)<<endl; MBlbl_int+=Uint; cout<<"bad"<<endl; // MBlbl_int.insert_w_lst(Uint.get_w_lst()); // MBlbl_int.insert_pole_lst(Uint.get_pole_lst()); //}// else more then one prop }// two prop formula
Uint operator%(Uint first, Uint second) { std::ostringstream sstream; sstream << first.getName() << " % " << second.getName(); return Uint( sstream.str()); }
Uint operator/( Uint left, Uint right ) { std::ostringstream sstream; sstream << left.getName() << " / " << right.getName(); return Uint( sstream.str()); }