static void test_IStream_invalid_operations(IStream * stream, DWORD mode) { HRESULT ret; IStream * clone; ULONG refcount; ULARGE_INTEGER uzero; ULARGE_INTEGER uret; LARGE_INTEGER zero; ULONG count; char data[256]; U(uzero).HighPart = 0; U(uzero).LowPart = 0; U(uret).HighPart = 0; U(uret).LowPart = 0; U(zero).HighPart = 0; U(zero).LowPart = 0; /* IStream::Read */ /* IStream_Read from the COBJMACROS is undefined by shlwapi.h, replaced by the IStream_Read helper function. */ ret = stream->lpVtbl->Read(stream, NULL, 0, &count); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); ret = stream->lpVtbl->Read(stream, data, 5, NULL); ok(ret == S_FALSE || ret == S_OK, "expected S_FALSE or S_OK, got 0x%08x\n", ret); ret = stream->lpVtbl->Read(stream, data, 0, NULL); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); ret = stream->lpVtbl->Read(stream, data, 3, &count); ok(ret == S_FALSE || ret == S_OK, "expected S_FALSE or S_OK, got 0x%08x\n", ret); /* IStream::Write */ /* IStream_Write from the COBJMACROS is undefined by shlwapi.h, replaced by the IStream_Write helper function. */ ret = stream->lpVtbl->Write(stream, NULL, 0, &count); if (mode == STGM_READ) { ok(ret == STG_E_ACCESSDENIED /* XP */ || broken(ret == S_OK) /* Win2000 + IE5 */, "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret); } else ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); strcpy(data, "Hello"); ret = stream->lpVtbl->Write(stream, data, 5, NULL); if (mode == STGM_READ) ok(ret == STG_E_ACCESSDENIED, "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret); else ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); strcpy(data, "Hello"); ret = stream->lpVtbl->Write(stream, data, 0, NULL); if (mode == STGM_READ) ok(ret == STG_E_ACCESSDENIED, "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret); else ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); strcpy(data, "Hello"); ret = stream->lpVtbl->Write(stream, data, 0, &count); if (mode == STGM_READ) ok(ret == STG_E_ACCESSDENIED, "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret); else ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); strcpy(data, "Hello"); ret = stream->lpVtbl->Write(stream, data, 3, &count); if (mode == STGM_READ) ok(ret == STG_E_ACCESSDENIED, "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret); else ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); /* IStream::Seek */ ret = IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); ret = IStream_Seek(stream, zero, 20, NULL); ok(ret == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", ret); /* IStream::CopyTo */ ret = IStream_CopyTo(stream, NULL, uzero, &uret, &uret); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); clone = NULL; ret = IStream_CopyTo(stream, clone, uzero, &uret, &uret); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); ret = IStream_CopyTo(stream, stream, uzero, &uret, &uret); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); ret = IStream_CopyTo(stream, stream, uzero, &uret, NULL); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); ret = IStream_CopyTo(stream, stream, uzero, NULL, &uret); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); /* IStream::Commit */ ret = IStream_Commit(stream, STGC_DEFAULT); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); /* IStream::Revert */ ret = IStream_Revert(stream); ok(ret == E_NOTIMPL, "expected E_NOTIMPL, got 0x%08x\n", ret); /* IStream::LockRegion */ ret = IStream_LockRegion(stream, uzero, uzero, 0); ok(ret == E_NOTIMPL /* XP */ || ret == S_OK /* Vista */, "expected E_NOTIMPL or S_OK, got 0x%08x\n", ret); /* IStream::UnlockRegion */ if (ret == E_NOTIMPL) /* XP */ { ret = IStream_UnlockRegion(stream, uzero, uzero, 0); ok(ret == E_NOTIMPL, "expected E_NOTIMPL, got 0x%08x\n", ret); } else /* Vista */ { ret = IStream_UnlockRegion(stream, uzero, uzero, 0); ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret); ret = IStream_UnlockRegion(stream, uzero, uzero, 0); ok(ret == STG_E_LOCKVIOLATION, "expected STG_E_LOCKVIOLATION, got 0x%08x\n", ret); } /* IStream::Stat */ ret = IStream_Stat(stream, NULL, 0); ok(ret == STG_E_INVALIDPOINTER, "expected STG_E_INVALIDPOINTER or E_NOTIMPL, got 0x%08x\n", ret); /* IStream::Clone */ /* Passing a NULL pointer for the second IStream::Clone param crashes on Win7 */ clone = NULL; ret = IStream_Clone(stream, &clone); ok(ret == E_NOTIMPL, "expected E_NOTIMPL, got 0x%08x\n", ret); ok(clone == NULL, "expected a NULL IStream object, got %p\n", stream); if (clone) { refcount = IStream_Release(clone); ok(refcount == 0, "expected 0, got %d\n", refcount); } }
void VelocityPenaltyAdjointStabilization<Mu>::element_constraint( bool compute_jacobian, AssemblyContext& context, CachedValues& /*cache*/ ) { #ifdef GRINS_USE_GRVY_TIMERS this->_timer->BeginTimer("VelocityPenaltyAdjointStabilization::element_constraint"); #endif // The number of local degrees of freedom in each variable. const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size(); const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size(); // Element Jacobian * quadrature weights for interior integration. const std::vector<libMesh::Real> &JxW = context.get_element_fe(this->_flow_vars.u())->get_JxW(); const std::vector<libMesh::Point>& u_qpoint = context.get_element_fe(this->_flow_vars.u())->get_xyz(); const std::vector<std::vector<libMesh::Real> >& u_phi = context.get_element_fe(this->_flow_vars.u())->get_phi(); const std::vector<std::vector<libMesh::RealGradient> >& p_dphi = context.get_element_fe(this->_press_var.p())->get_dphi(); libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p()); // R_{p} libMesh::DenseSubMatrix<libMesh::Number> &Kpu = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.u()); // J_{pu} libMesh::DenseSubMatrix<libMesh::Number> &Kpv = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.v()); // J_{pv} libMesh::DenseSubMatrix<libMesh::Number> *Kpw = NULL; if(this->mesh_dim(context) == 3) { Kpw = &context.get_elem_jacobian (this->_press_var.p(), this->_flow_vars.w()); // J_{pw} } // Now we will build the element Jacobian and residual. // Constructing the residual requires the solution and its // gradient from the previous timestep. This must be // calculated at each quadrature point by summing the // solution degree-of-freedom values by the appropriate // weight functions. unsigned int n_qpoints = context.get_element_qrule().n_points(); libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u()); for (unsigned int qp=0; qp != n_qpoints; qp++) { libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp ); libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp ); libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ), context.interior_value( this->_flow_vars.v(), qp ) ); if( this->mesh_dim(context) == 3 ) { U(2) = context.interior_value( this->_flow_vars.w(), qp ); } // Compute the viscosity at this qp libMesh::Real mu_qp = this->_mu(context, qp); libMesh::Real tau_M; libMesh::Real d_tau_M_d_rho; libMesh::Gradient d_tau_M_dU; if (compute_jacobian) this->_stab_helper.compute_tau_momentum_and_derivs ( context, qp, g, G, this->_rho, U, mu_qp, tau_M, d_tau_M_d_rho, d_tau_M_dU, this->_is_steady ); else tau_M = this->_stab_helper.compute_tau_momentum ( context, qp, g, G, this->_rho, U, mu_qp, this->_is_steady ); libMesh::NumberVectorValue F; libMesh::NumberTensorValue dFdU; libMesh::NumberTensorValue* dFdU_ptr = compute_jacobian ? &dFdU : NULL; if (!this->compute_force(u_qpoint[qp], context, U, F, dFdU_ptr)) continue; // First, an i-loop over the velocity degrees of freedom. // We know that n_u_dofs == n_v_dofs so we can compute contributions // for both at the same time. for (unsigned int i=0; i != n_p_dofs; i++) { Fp(i) += -tau_M*F*p_dphi[i][qp]*JxW[qp]; if (compute_jacobian) { for (unsigned int j=0; j != n_u_dofs; ++j) { Kpu(i,j) += -d_tau_M_dU(0)*u_phi[j][qp]*F*p_dphi[i][qp]*JxW[qp]*context.get_elem_solution_derivative(); Kpv(i,j) += -d_tau_M_dU(1)*u_phi[j][qp]*F*p_dphi[i][qp]*JxW[qp]*context.get_elem_solution_derivative(); for (unsigned int d=0; d != 3; ++d) { Kpu(i,j) += -tau_M*dFdU(d,0)*u_phi[j][qp]*p_dphi[i][qp](d)*JxW[qp]*context.get_elem_solution_derivative(); Kpv(i,j) += -tau_M*dFdU(d,1)*u_phi[j][qp]*p_dphi[i][qp](d)*JxW[qp]*context.get_elem_solution_derivative(); } } if( this->mesh_dim(context) == 3 ) for (unsigned int j=0; j != n_u_dofs; ++j) { (*Kpw)(i,j) += -d_tau_M_dU(2)*u_phi[j][qp]*F*p_dphi[i][qp]*JxW[qp]*context.get_elem_solution_derivative(); for (unsigned int d=0; d != 3; ++d) { (*Kpw)(i,j) += -tau_M*dFdU(d,2)*u_phi[j][qp]*p_dphi[i][qp](d)*JxW[qp]*context.get_elem_solution_derivative(); } } } } } // End quadrature loop #ifdef GRINS_USE_GRVY_TIMERS this->_timer->EndTimer("VelocityPenaltyAdjointStabilization::element_constraint"); #endif return; }
F(vcsel, 2, N("sf"), N("zf")) F(swz, 3, N("lo"), N("hi")) static struct insn tabaslctop[] = { { 0x00000000, 0x000001e0, SESTART, N("slct"), CSRCP, N("sf"), ASRC2D, SEEND }, { 0x00000020, 0x000001e0, SESTART, N("slct"), CSRCP, N("zf"), ASRC2D, SEEND }, { 0x00000040, 0x000001e0, SESTART, N("slct"), CSRCP, N("b19"), ASRC2D, SEEND }, { 0x00000060, 0x000001e0, SESTART, N("slct"), CSRCP, N("b20d"), ASRC2D, SEEND }, { 0x00000080, 0x000001e0, SESTART, N("slct"), CSRCP, N("b20"), ASRC2Q, SEEND }, { 0x000000a0, 0x000001e0, SESTART, N("slct"), CSRCP, N("b21"), ASRC2D, SEEND }, { 0x000000c0, 0x000001e0, SESTART, N("slct"), CSRCP, N("b19a"), ASRC2D, SEEND }, { 0x000000e0, 0x000001e0, SESTART, N("slct"), CSRCP, N("b18"), ASRC2D, SEEND }, { 0x00000100, 0x000001e0, SESTART, N("slct"), CSRCP, N("asf"), ASRC2D, SEEND }, { 0x00000120, 0x000001e0, SESTART, N("slct"), CSRCP, N("azf"), ASRC2D, SEEND }, { 0x00000140, 0x000001e0, SESTART, N("slct"), CSRCP, N("aef"), ASRC2D, SEEND }, { 0x00000160, 0x000001e0, SESTART, N("slct"), CSRCP, U("11"), ASRC2D, SEEND }, { 0x00000180, 0x000001e0, SESTART, N("slct"), CSRCP, U("12"), ASRC2D, SEEND }, { 0x000001a0, 0x000001e0, SESTART, N("slct"), CSRCP, N("lzf"), ASRC2D, SEEND }, { 0x000001c0, 0x000001e0, ASRC2 }, { 0x000001e0, 0x000001e0, SESTART, N("slct"), CSRCP, N("true"), ASRC2D, SEEND }, { 0, 0, OOPS } }; static struct insn tabslctop[] = { { 0x00000000, 0x000001e0, SESTART, N("slct"), CSRCP, N("sf"), RSRC2D, SEEND }, { 0x00000020, 0x000001e0, SESTART, N("slct"), CSRCP, N("zf"), RSRC2D, SEEND }, { 0x00000040, 0x000001e0, SESTART, N("slct"), CSRCP, N("b19"), RSRC2D, SEEND }, { 0x00000060, 0x000001e0, SESTART, N("slct"), CSRCP, N("b20d"), RSRC2D, SEEND }, { 0x00000080, 0x000001e0, SESTART, N("slct"), CSRCP, N("b20"), RSRC2Q, SEEND }, { 0x000000a0, 0x000001e0, SESTART, N("slct"), CSRCP, N("b21"), RSRC2D, SEEND }, { 0x000000c0, 0x000001e0, SESTART, N("slct"), CSRCP, N("b19a"), RSRC2D, SEEND },
void GrayScott::step() { // update step ++currStep_; // u and v at the half step std::vector<double> uHalf(Ntot_); std::vector<double> vHalf(Ntot_); // right hand sides for u and for v std::vector<double> uRhs(N_); std::vector<double> vRhs(N_); double uCoeff = Du_*dt_/(2.*dx_*dx_); double vCoeff = Dv_*dt_/(2.*dx_*dx_); /****************** DIFFUSION (ADI) ***************************************/ // perform the first half-step // loop over all rows // j=0 for (int i=0; i<N_; ++i) { uRhs[i] = U(i,0) + uCoeff * (U(i,1) - U(i,0)); vRhs[i] = V(i,0) + vCoeff * (V(i,1) - V(i,0)); } TriDiagMatrixSolver::solve(N_, matU1_, uRhs, &UHALF(0,0), 1); TriDiagMatrixSolver::solve(N_, matV1_, vRhs, &VHALF(0,0), 1); // inner grid points for (int j=1; j<N_-1; ++j) { // create right-hand side of the systems for (int i=0; i<N_; ++i) { uRhs[i] = U(i,j) + uCoeff * (U(i,j+1) - 2.*U(i,j) + U(i,j-1)); vRhs[i] = V(i,j) + vCoeff * (V(i,j+1) - 2.*V(i,j) + V(i,j-1)); } TriDiagMatrixSolver::solve(N_, matU1_, uRhs, &UHALF(0,j), 1); TriDiagMatrixSolver::solve(N_, matV1_, vRhs, &VHALF(0,j), 1); } // j=N_-1 for (int i=0; i<N_; ++i) { uRhs[i] = U(i,N_-1) + uCoeff * (- U(i,N_-1) + U(i,N_-2)); vRhs[i] = V(i,N_-1) + vCoeff * (- V(i,N_-1) + V(i,N_-2)); } TriDiagMatrixSolver::solve(N_, matU1_, uRhs, &UHALF(0,N_-1), 1); TriDiagMatrixSolver::solve(N_, matV1_, vRhs, &VHALF(0,N_-1), 1); // perform the second half-step // loop over all columns // i=0 for (int j=0; j<N_; ++j) { uRhs[j] = UHALF(0,j) + uCoeff * (UHALF(1,j) - UHALF(0,j)); vRhs[j] = VHALF(0,j) + vCoeff * (VHALF(1,j) - VHALF(0,j)); } TriDiagMatrixSolver::solve(N_, matU2_, uRhs, &U(0,0), N_); TriDiagMatrixSolver::solve(N_, matV2_, vRhs, &V(0,0), N_); // inner grid points for (int i=1; i<N_-1; ++i) { // create right-hand side of the systems for (int j=0; j<N_; ++j) { uRhs[j] = UHALF(i,j) + uCoeff * (UHALF(i+1,j) - 2.*UHALF(i,j) + UHALF(i-1,j)); vRhs[j] = VHALF(i,j) + vCoeff * (VHALF(i+1,j) - 2.*VHALF(i,j) + VHALF(i-1,j)); } TriDiagMatrixSolver::solve(N_, matU2_, uRhs, &U(i,0), N_); TriDiagMatrixSolver::solve(N_, matV2_, vRhs, &V(i,0), N_); } // i=N_-1 for (int j=0; j<N_; ++j) { uRhs[j] = UHALF(N_-1,j) + uCoeff * (- UHALF(N_-1,j) + UHALF(N_-2,j)); vRhs[j] = VHALF(N_-1,j) + vCoeff * (- VHALF(N_-1,j) + VHALF(N_-2,j)); } TriDiagMatrixSolver::solve(N_, matU2_, uRhs, &U(N_-1,0), N_); TriDiagMatrixSolver::solve(N_, matV2_, vRhs, &V(N_-1,0), N_); /****************** REACTION **********************************************/ double tmp; for (int i=0; i<N_; ++i) { for (int j=0; j<N_; ++j) { tmp = U(i,j); U(i,j) += dt_ * ( -U(i,j)*V(i,j)*V(i,j) + F_*(1.-U(i,j)) ); V(i,j) += dt_ * ( tmp*V(i,j)*V(i,j) - (F_+k_)*V(i,j) ); } } }
Real NSEnergyViscousBC::computeQpOffDiagJacobian(unsigned jvar) { // Note: This function requires both _vst_derivs *and* _temp_derivs // Convenience variables const RealTensorValue & tau = _viscous_stress_tensor[_qp]; Real rho = _rho[_qp]; Real phij = _phi[_j][_qp]; RealVectorValue U(_rho_u[_qp], _rho_v[_qp], _rho_w[_qp]); // Map jvar into the variable m for our problem, regardless of // how Moose has numbered things. unsigned m = this->map_var_number(jvar); // // 1.) Thermal term derivatives // // See notes for this term, involves temperature Hessian Real thermal_term = 0.; for (unsigned ell=0; ell<LIBMESH_DIM; ++ell) { Real intermediate_result = 0.; // The temperature Hessian contribution for (unsigned n=0; n<5; ++n) intermediate_result += _temp_derivs.get_hess(m, n) * (*_gradU[n])[_qp](ell); // Hit Hessian contribution with test function intermediate_result *= _phi[_j][_qp]; // Add in the temperature gradient contribution intermediate_result += _temp_derivs.get_grad(m) * _grad_phi[_j][_qp](ell); // Hit the result with the normal component, accumulate in thermal_term thermal_term += intermediate_result * _normals[_qp](ell); } // Hit thermal_term with thermal conductivity thermal_term *= _thermal_conductivity[_qp]; // // 2.) Viscous term derivatives // // Compute viscous term derivatives Real visc_term = 0.; switch ( m ) { case 0: // density { // Loop over k and ell as in the notes... for (unsigned k=0; k<LIBMESH_DIM; ++k) { Real intermediate_value = 0.; for (unsigned ell=0; ell<LIBMESH_DIM; ++ell) intermediate_value += ( (U(ell)/rho)*(-tau(k,ell)*phij/rho + _vst_derivs.dtau(k,ell,m)) ); // Hit accumulated value with normal component k. We will multiply by test function at // the end of this routine... visc_term += intermediate_value * _normals[_qp](k); } // end for k break; } // end case 0 case 1: case 2: case 3: // momentums { // Map m -> 0,1,2 as usual... unsigned m_local = m-1; // Loop over k and ell as in the notes... for (unsigned k=0; k<LIBMESH_DIM; ++k) { Real intermediate_value = tau(k,m_local)*phij/rho; for (unsigned ell=0; ell<LIBMESH_DIM; ++ell) intermediate_value += _vst_derivs.dtau(k,ell,m) * U(ell)/rho; // Note: pass 'm' to dtau, it will convert it internally // Hit accumulated value with normal component k. visc_term += intermediate_value * _normals[_qp](k); } // end for k break; } // end case 1,2,3 case 4: // energy mooseError("Shouldn't get here, this is the on-diagonal entry!"); break; default: mooseError("Invalid m value."); break; } // Finally, sum up the different contributions (with appropriate // sign) multiply by the test function, and return. return (-thermal_term - visc_term) * _test[_i][_qp]; }
/* Kabsch alignment */ void kabsch_alignment( std::vector<float> ref, std::vector<float> tar, t_tiltdata &data, gmx_bool bVerbose) { if (ref.size() != tar.size()) { std::cerr << "\nError! Sizes of reference coordinate matrix and simulated structure coordinate matrices do not match!" << std::endl; std::exit(1); } int ncoords = ref.size(); int natoms = ncoords/3; // Center the two selections std::vector<float> stsel1(ncoords,0), stsel2(ncoords,0), stsel2T(ncoords,0); std::vector<float> ref_com(3,0), tar_com(3,0); average_coordinate(ref, ref_com); average_coordinate(tar, tar_com); for (int i=0; i<natoms; i++) { for (int j=0; j<3; j++) { stsel1[i+j*natoms] = ref[i+j*natoms] - ref_com[j]; stsel2[i+j*natoms] = tar[i+j*natoms] - tar_com[j]; } } // Initial residual float E0 = sdot(ncoords,&stsel1[0],1,&stsel1[0],1)+sdot(ncoords,&stsel2[0],1,&stsel2[0],1) ; // dot(target_transpose,reference) std::vector<float> T1_dot_2(3*natoms,0); sgemm('T','N',3,natoms,natoms,1,&stsel2[0],natoms,&stsel1[0],natoms,1,&T1_dot_2[0],3); // SVD of the dot product std::vector<float> U(9,0), S(3,0), V(9,0), work(5*9,0); int info; sgesvd('A','A',3,3,&T1_dot_2[0],3,&S[0],&U[0],3,&V[0],3,&work[0],9*5,info); /*std::cout << "\n S: "; for (int i=0;i<3;i++) { std::cout << S[i] << " "; } std::cout << "\n U: "; for (int i=0;i<9;i++) { std::cout << U[i] << " "; }*/ float reflect = det3x3(&U[0]) * det3x3(&V[0]); if ( 1 - reflect > 1e-5) { S[2] = -S[2]; U[6] = -U[6]; U[7] = -U[7]; U[8] = -U[8]; } float rmsd = sqrt(fabs( E0 - (2.0 * (S[0]+S[1]+S[2]) ) ) /natoms); // Rotation matrix is dot(U,V) std::vector<float> M(9,0); sgemm('N','N',3,3,3,1,&U[0],3,&V[0],3,1,&M[0],3); /* M = [ 0 3 6 ] = [ 00 01 02 ] [ 1 4 7 ] [ 10 11 12 ] [ 2 5 8 ] [ 20 21 22 ] */ float trace = M[0]+M[4]+M[8]; float angle = acos((trace-1)/2)*RAD2DEG; float rx,ry,rz,ux,uy,uz; rx = atan2(M[5],M[8])*RAD2DEG; ry = atan2(-M[2],sqrt(M[5]*M[5]+M[8]*M[8]))*RAD2DEG; rz = atan2(M[1],M[0])*RAD2DEG; float zeta = sqrt( (M[5]-M[7])*(M[5]-M[7]) + (M[6]-M[2])*(M[6]-M[2]) + (M[3]-M[1])*(M[3]-M[1]) ); //std::cout << "\n" << M[5] << " - " << M[7] << " = " << M[5]-M[7]; //std::cout << "\n" << M[6] << " - " << M[2] << " = " << M[6]-M[2]; //std::cout << "\n" << M[3] << " - " << M[1] << " = " << M[3]-M[1] << std::endl; ux = (M[5]-M[7])/zeta; uy = (M[6]-M[2])/zeta; uz = (M[3]-M[1])/zeta; //std::cout << zeta << " { " << ux << " " << uy << " " << uz << " }" << sqrt(ux*ux+uy*uy+uz*uz) << std:: endl; if (bVerbose) { fprintf(stdout,"%12s%12s%12s%12s%12s%12s%12s%12s\n","Angle(deg)","rmsd(nm)","x(deg)","y(deg)","z(deg)","ux(nm)","uy(nm)","uz(nm)"); fprintf(stdout,"%12.3f%12.6f%12.4f%12.4f%12.4f%12.4f%12.4f%12.4f\n",angle,rmsd,rx,ry,rz,ux,uy,uz); } data.rotation.push_back(angle); data.rmsd.push_back(rmsd); data.x_rotation.push_back(rx); data.y_rotation.push_back(ry); data.z_rotation.push_back(rz); data.x_rotation_axis.push_back(ux); data.y_rotation_axis.push_back(uy); data.z_rotation_axis.push_back(uz); return; }
Real INSSplitMomentum::computeQpOffDiagJacobian(unsigned jvar) { if ((jvar == _u_vel_var_number) || (jvar == _v_vel_var_number) || (jvar == _w_vel_var_number)) { // Derivative of viscous stress tensor RealTensorValue dtau; // Initialize to invalid value, then determine correct value. unsigned vel_index = 99; // Set index and build dtau for that index if (jvar == _u_vel_var_number) { vel_index = 0; dtau(0, 0) = 2. * _grad_phi[_j][_qp](0); dtau(0, 1) = _grad_phi[_j][_qp](1); dtau(0, 2) = _grad_phi[_j][_qp](2); dtau(1, 0) = _grad_phi[_j][_qp](1); dtau(2, 0) = _grad_phi[_j][_qp](2); } else if (jvar == _v_vel_var_number) { vel_index = 1; /* */ dtau(0, 1) = _grad_phi[_j][_qp](0); dtau(1, 0) = _grad_phi[_j][_qp](0); dtau(1, 1) = 2. * _grad_phi[_j][_qp](1); dtau(1, 2) = _grad_phi[_j][_qp](2); /* */ dtau(2, 1) = _grad_phi[_j][_qp](2); } else if (jvar == _w_vel_var_number) { vel_index = 2; /* */ dtau(0, 2) = _grad_phi[_j][_qp](0); /* */ dtau(1, 2) = _grad_phi[_j][_qp](1); dtau(2, 0) = _grad_phi[_j][_qp](0); dtau(2, 1) = _grad_phi[_j][_qp](1); dtau(2, 2) = 2. * _grad_phi[_j][_qp](2); } // Vector object for test function RealVectorValue test; test(_component) = _test[_i][_qp]; // Vector object for U RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]); // Tensor object for test function gradient RealTensorValue grad_test; for (unsigned k = 0; k < 3; ++k) grad_test(_component, k) = _grad_test[_i][_qp](k); // Compute the convective part RealVectorValue convective_jac = _phi[_j][_qp] * RealVectorValue(_grad_u_vel[_qp](vel_index), _grad_v_vel[_qp](vel_index), _grad_w_vel[_qp](vel_index)); // Extra contribution in vel_index component convective_jac(vel_index) += U * _grad_phi[_j][_qp]; Real convective_part = convective_jac * test; // Compute the viscous part Real viscous_part = (_mu[_qp] / _rho[_qp]) * dtau.contract(grad_test); // Return the result return convective_part + viscous_part; } else return 0; }
static int DrawGrid (lua_State * L) { DrawGrid(F(L, 1), F(L, 2), F(L, 3), F(L, 4), F(L, 5), F(L, 6), F(L, 7), U(L, 8), U(L, 9)); return 0; }
Error Is::getOrCreatePipeline(ShaderVariantBit variantMask, RenderingContext& ctx, PipelinePtr& ppline) { auto it = m_shaderVariantMap.find(variantMask); if(it != m_shaderVariantMap.getEnd()) { ppline = it->m_lightPpline; } else { StringAuto pps(ctx.m_tempAllocator); pps.sprintf("#define TILE_COUNT_X %u\n" "#define TILE_COUNT_Y %u\n" "#define CLUSTER_COUNT %u\n" "#define RENDERER_WIDTH %u\n" "#define RENDERER_HEIGHT %u\n" "#define MAX_LIGHT_INDICES %u\n" "#define POISSON %u\n" "#define INDIRECT_ENABLED %u\n" "#define IR_MIPMAP_COUNT %u\n" "#define POINT_LIGHTS_ENABLED %u\n" "#define SPOT_LIGHTS_ENABLED %u\n" "#define DECALS_ENABLED %u\n" "#define POINT_LIGHTS_SHADOWS_ENABLED %u\n" "#define SPOT_LIGHTS_SHADOWS_ENABLED %u\n", m_r->getTileCountXY().x(), m_r->getTileCountXY().y(), m_clusterCount, m_r->getWidth(), m_r->getHeight(), m_maxLightIds, m_r->getSm().getPoissonEnabled(), !!(variantMask & ShaderVariantBit::INDIRECT), m_r->getIr().getReflectionTextureMipmapCount(), !!(variantMask & ShaderVariantBit::P_LIGHTS), !!(variantMask & ShaderVariantBit::S_LIGHTS), !!(variantMask & ShaderVariantBit::DECALS), !!(variantMask & ShaderVariantBit::P_LIGHTS_SHADOWS), !!(variantMask & ShaderVariantBit::S_LIGHTS_SHADOWS)); ShaderVariant variant; ANKI_CHECK(getResourceManager().loadResourceToCache( variant.m_lightFrag, "shaders/Is.frag.glsl", pps.toCString(), "r_")); PipelineInitInfo init; init.m_inputAssembler.m_topology = PrimitiveTopology::TRIANGLE_STRIP; init.m_depthStencil.m_depthWriteEnabled = false; init.m_depthStencil.m_depthCompareFunction = CompareOperation::ALWAYS; init.m_color.m_attachmentCount = 1; init.m_color.m_attachments[0].m_format = IS_COLOR_ATTACHMENT_PIXEL_FORMAT; init.m_shaders[U(ShaderType::VERTEX)] = m_lightVert->getGrShader(); init.m_shaders[U(ShaderType::FRAGMENT)] = m_lightFrag->getGrShader(); variant.m_lightPpline = getGrManager().newInstance<Pipeline>(init); ppline = variant.m_lightPpline; m_shaderVariantMap.pushBack(getAllocator(), variantMask, variant); } return ErrorCode::NONE; }
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { case 0: // { } if (record->event.pressed) { return MACRO(T(ENT), D(LSFT), T(LBRC), U(LSFT), T(ENT), D(LSFT), T(RBRC), U(LSFT), T(UP), T(TAB), END); } break; case 1: if (record->event.pressed) { return MACRO(T(0), T(X), END); } break; case 2: if (record->event.pressed) { SEND_STRING("public"); } break; case 3: if (record->event.pressed) { SEND_STRING("protected"); } break; case 4: if (record->event.pressed) { SEND_STRING("private"); } break; case 5: // class if (record->event.pressed) { return MACRO(T(C), T(L), T(A), T(S), T(S), T(ENT), D(LSFT), T(LBRC), U(LSFT), T(ENT), T(P), T(U), T(B), T(L), T(I), T(C), D(LSFT), T(SCLN), U(LSFT), T(ENT), T(ENT), T(P), T(R), T(I), T(V), T(A), T(T), T(E), D(LSFT), T(SCLN), U(LSFT), T(ENT), D(LSFT), T(RBRC), U(LSFT), T(SCLN), T(ENT), T(UP), T(UP), T(UP), T(UP), T(UP), T(UP), T(UP), T(END), T(SPC), END); } break; case 6: // struct if (record->event.pressed) { return MACRO(T(S), T(T), T(R), T(U), T(C), T(T), T(ENT), D(LSFT), T(LBRC), U(LSFT), T(ENT), D(LSFT), T(RBRC), U(LSFT), T(SCLN), T(ENT), T(UP), T(UP), T(UP), T(UP), T(END), T(SPC), END); } break; case 7: if (record->event.pressed) { SEND_STRING("return"); } break; case 8: // #include if (record->event.pressed) { return MACRO(T(NONUS_HASH), T(I), T(N), T(C), T(L), T(U), T(D), T(E), END); } break; case 9: if (record->event.pressed) { SEND_STRING("objdump -CT -x -d"); } break; case 10: if (record->event.pressed) { SEND_STRING("git log --oneline --graph --decorate=short"); } break; case 11: if (record->event.pressed) { SEND_STRING("good morning"); } break; case 12: if (record->event.pressed) { SEND_STRING("namespace"); } break; case 14: // emacs toggle read-only if (record->event.pressed) { return MACRO(D(LCTL), T(X), T(Q), U(LCTL), END); } break; case 15: // emacs write buffer if (record->event.pressed) { return MACRO(D(LCTL), T(X), T(S), U(LCTL), END); } break; case 16: // emacs undo if (record->event.pressed) { return MACRO(D(LCTL), D(LSFT), T(MINS), U(LSFT), U(LCTL), END); } break; case 17: // emacs redo if (record->event.pressed) { return MACRO(D(LALT), D(LSFT), T(MINS), U(LSFT), U(LALT), END); } break; case 18: // emacs previous buffer if (record->event.pressed) { return MACRO(D(LCTL), T(X), U(LCTL), T(LEFT), END); } break; case 19: // emacs next buffer if (record->event.pressed) { return MACRO(D(LCTL), T(X), U(LCTL), T(RGHT), END); } break; case 20: if (record->event.pressed) { SEND_STRING("good night"); } break; case 22: // { }; if (record->event.pressed) { return MACRO(T(ENT), D(LSFT), T(LBRC), U(LSFT), T(ENT), D(LSFT), T(RBRC), U(LSFT), T(SCLN), T(UP), T(TAB), END); } break; case 23: if (record->event.pressed) { SEND_STRING("template"); } break; case 24: if (record->event.pressed) { SEND_STRING("typename"); } break; case 25: if (record->event.pressed) { SEND_STRING("continue"); return MACRO(T(SCLN), END); } break; case 26: if (record->event.pressed) { SEND_STRING("break"); return MACRO(T(SCLN), END); } break; case 27: if (record->event.pressed) { SEND_STRING("const"); } break; case 28: if (record->event.pressed) { SEND_STRING(":-)"); } break; case 29: if (record->event.pressed) { SEND_STRING(":-("); } break; case 30: // dazed if (record->event.pressed) { send_keystrokes(NK_DOWN, KC_LSFT, KC_8, KC_MINS, KC_8, NK_UP, KC_LSFT, KC_NO); } break; case 31: // decaf if (record->event.pressed) { send_keystrokes(NK_DOWN, KC_LSFT, KC_C, KC_9, KC_MINS, KC_0, NK_UP, KC_LSFT, KC_NO); } break; case 32: if (record->event.pressed) { SEND_STRING("operator"); } break; case 33: if (record->event.pressed) { SEND_STRING("nullptr"); } break; case 34: if (record->event.pressed) { SEND_STRING("extern"); } break; case 35: if (record->event.pressed) { SEND_STRING("virtual"); } break; case 36: // emacs font smaller if (record->event.pressed) { return MACRO(D(LCTL), T(X), T(EQL), U(LCTL), END); } break; case 37: // emacs font bigger if (record->event.pressed) { return MACRO(D(LCTL), T(X), T(MINS), U(LCTL), END); } break; case 38: if (record->event.pressed) { SEND_STRING("volatile"); } break; } return MACRO_NONE; }
0x4b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0x11, 0x2f, 0xaf, 0xb5, 0x90, 0x04, 0x1b, 0xec, 0x50, 0x3b, 0xec, 0xdc, 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x66, 0x28, 0xea, 0x37, 0x80, 0xc5, 0x01, 0x16, 0x00, 0x77, 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x33, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x24, 0x00, 0x76, 0xff, 0xff, 0xff, 0x37, 0xd5, 0xb0, 0xf7, 0x24, 0xf0, 0xd6, 0xd4, 0xec, 0x09, 0x86, 0x5a, 0xa0, 0xe8, 0xc3, 0xa9, 0x00, 0x00, 0x00, 0x00, 0x76, 0xff, 0xff, 0xff, 0xb4, 0xd8, 0xb8, 0xfe, 0x83, 0xb3, 0x13, 0x3f, 0xfc, 0x5c, 0x41, 0xad, 0xe2, 0x64, 0x83, 0xe0, 0x00, 0x00, 0x00, 0x00 }; static unsigned int type_1_length = 472; static const krb5_keyblock kdc_keyblock = { 0, ENCTYPE_ARCFOUR_HMAC, 16, U("\xB2\x86\x75\x71\x48\xAF\x7F\xD2\x52\xC5\x36\x03\xA1\x50\xB7\xE7") }; static const krb5_keyblock member_keyblock = { 0, ENCTYPE_ARCFOUR_HMAC, 16, U("\xD2\x17\xFA\xEA\xE5\xE6\xB5\xF9\x5C\xCC\x94\x07\x7A\xB8\xA5\xFC") }; static time_t authtime = 1120440609; static const char *user = "******"; /* The S4U2Self PACs below were collected by debugging krb5-mit code on * Linux, talking with a Windows 2008 KDC server over the network. */ static const unsigned char s4u_pac_regular[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { case MC_COPY_LINE: if (record->event.pressed) { return MACRO( T(HOME), D(LSFT), T(END), U(LSFT), D(LCTL), T(C), U(LCTL), END); } break; case MC_CUT_LINE: if (record->event.pressed) { return MACRO( T(HOME), D(LSFT), T(END), U(LSFT), D(LCTL), T(X), U(LCTL), END); } break; case MC_PASTE_LINE: if (record->event.pressed) { return MACRO( T(END), T(ENTER), D(LCTL), T(V), U(LCTL), END); } break; case MC_NEW_SEARCH_TAB: if (record->event.pressed) { return MACRO( D(LCTL), T(T), T(K), U(LCTL), END); } break; case SCREEN_TAB_LEFT: if (record->event.pressed) { return MACRO( D(LCTL), T(A), U(LCTL), T(P), END); } break; case SCREEN_TAB_RIGHT: if (record->event.pressed) { return MACRO( D(LCTL), T(A), U(LCTL), T(N), END); } break; case SCREEN_NEW_TAB: if (record->event.pressed) { return MACRO( D(LCTL), T(A), U(LCTL), T(C), END); } break; case SCREEN_COPY_MODE: if (record->event.pressed) { return MACRO( D(LCTL), T(A), U(LCTL), T(ESC), END); } break; case SCREEN_PASTE: if (record->event.pressed) { return MACRO( D(LCTL), T(A), U(LCTL), T(RBRC), END); } break; case SWITCH_NDS: if (record->event.pressed) { return MACRO( D(LSFT), T(F11), U(LSFT), W(500), D(LALT), T(TAB), U(LALT), END); } break; case OPEN_CLOSE_PAREN: if (record->event.pressed) { return MACRO( D(LSFT), T(LPRN), T(RPRN), U(LSFT), T(LEFT), END); } break; case OPEN_CLOSE_BRACKET: if (record->event.pressed) { return MACRO( T(LBRC), T(RBRC), T(LEFT), END); } break; case OPEN_CLOSE_CURLY: if (record->event.pressed) { return MACRO( D(LSFT), T(LCBR), T(RCBR), U(LSFT), T(LEFT), END); } break; case OPEN_CLOSE_SINGLE_QUOTE: if (record->event.pressed) { return MACRO( T(QUOT), T(QUOT), T(LEFT), END); } break; case OPEN_CLOSE_DOUBLE_QUOTE: if (record->event.pressed) { return MACRO( D(LSFT), T(QUOT), T(QUOT), U(LSFT), T(LEFT), END); } break; case SHELL_RECALL_LAST_ARG_REMOVE_FIRST_COMMAND: if (record->event.pressed) { return MACRO( T(UP), T(HOME), D(LALT), T(D), U(LALT), END); } break; case SEMICOLON_NEWLINE: if (record->event.pressed) { return MACRO( T(END), T(SCLN), T(ENTER), END); } break; case END_NEWLINE: if (record->event.pressed) { return MACRO( T(END), T(ENTER), END); } break; } return MACRO_NONE; };
double MQuadrangle::getInnerRadius() { #if defined(HAVE_LAPACK) // get the coordinates (x, y, z) of the 4 points defining the Quad double x[4] = {_v[0]->x(), _v[1]->x(), _v[2]->x(), _v[3]->x()}; double y[4] = {_v[0]->y(), _v[1]->y(), _v[2]->y(), _v[3]->y()}; double z[4] = {_v[0]->z(), _v[1]->z(), _v[2]->z(), _v[3]->z()}; // get the coefficient (a,b,c,d) of the mean plane - least square! // the plane has for equation " a*x+b*y+c*z+d=0 " // compute the centroid of the 4 points double xm = (x[0] + x[1] + x[2] + x[3]) / 4; double ym = (y[0] + y[1] + y[2] + y[3]) / 4; double zm = (z[0] + z[1] + z[2] + z[3]) / 4; // using svd decomposition fullMatrix<double> U(4,3), V(3,3); fullVector<double> sigma(3); for (int i = 0; i < 4; i++) { U(i, 0) = x[i] - xm; U(i, 1) = y[i] - ym; U(i, 2) = z[i] - zm; } U.svd(V, sigma); double svd[3]; svd[0] = sigma(0); svd[1] = sigma(1); svd[2] = sigma(2); int min; if(fabs(svd[0]) < fabs(svd[1]) && fabs(svd[0]) < fabs(svd[2])) min = 0; else if(fabs(svd[1]) < fabs(svd[0]) && fabs(svd[1]) < fabs(svd[2])) min = 1; else min = 2; double a = V(0, min); double b = V(1, min); double c = V(2, min); double d = -(xm * a + ym * b + zm * c); double norm = sqrt(a*a+b*b+c*c); // projection of the 4 original points on the mean_plane double xp[4], yp[4], zp[4]; for (int i = 0; i < 4; i++) { xp[i] = ((b*b+c*c)*x[i]-a*b*y[i]-a*c*z[i]-d*a)/norm; yp[i] = (-a*b*x[i]+(a*a+c*c)*y[i]-b*c*z[i]-d*b)/norm; zp[i] = (-a*c*x[i]-b*c*y[i]+(a*a+b*b)*z[i]-d*c)/norm; } // go from XYZ-plane to XY-plane // 4 points, 4 edges => 4 inner radii of circles tangent to (at // least) 3 of the four edges! double xn[4], yn[4], r[4]; planarQuad_xyz2xy(xp, yp, zp, xn, yn); // compute for each of the 4 possibilities the incircle radius, // keeping the minimum double R = 1.e22; for (int j = 0; j < 4; j++){ r[j] = computeInnerRadiusForQuad(xn, yn, j); if(r[j] < R){ R = r[j]; } } return R; #else // HAVE_LAPACK // Default implementation. Not sure that the following give exactly // the same value as the HAVE_LAPACK case ! // but same value for a square // Mid-point of each edge of the quadrangle SPoint3 A(_v[0]->x()+_v[1]->x(),_v[0]->y()+_v[1]->y(),_v[0]->z()+_v[1]->z()); SPoint3 B(_v[1]->x()+_v[2]->x(),_v[1]->y()+_v[2]->y(),_v[1]->z()+_v[2]->z()); SPoint3 C(_v[2]->x()+_v[3]->x(),_v[2]->y()+_v[3]->y(),_v[2]->z()+_v[3]->z()); SPoint3 D(_v[3]->x()+_v[0]->x(),_v[3]->y()+_v[0]->y(),_v[3]->z()+_v[0]->z()); A*=0.5; B*=0.5; C*=0.5; D*=0.5; // compute the length of the side double a = A.distance(B); double b = B.distance(C); double c = C.distance(D); double d = D.distance(A); // perimeter double s = a+b+c+d; double halfs = 0.5*s; return 0.25*sqrt( (a*c+b*d)*(a*d+b*c)*(a*b+c*d)/ ((halfs-a)*(halfs-b)*(halfs-c)*(halfs-d)) ); #endif // HAVE_LAPACK }
void LamentStress<EvalT, Traits>:: evaluateFields(typename Traits::EvalData workset) { Teuchos::RCP<lament::matParams<ScalarT>> matp = Teuchos::rcp(new lament::matParams<ScalarT>()); // Get the old state data Albany::MDArray oldDefGrad = (*workset.stateArrayPtr)[defGradName]; Albany::MDArray oldStress = (*workset.stateArrayPtr)[stressName]; int numStateVariables = (int)(this->lamentMaterialModelStateVariableNames.size()); // \todo Get actual time step for calls to LAMENT materials. double deltaT = 1.0; vector<ScalarT> strainRate(6); // symmetric tensor vector<ScalarT> spin(3); // skew-symmetric tensor vector<ScalarT> defGrad(9); // symmetric tensor vector<ScalarT> leftStretch(6); // symmetric tensor vector<ScalarT> rotation(9); // full tensor vector<double> stressOld(6); // symmetric tensor vector<ScalarT> stressNew(6); // symmetric tensor vector<double> stateOld(numStateVariables); // a single scalar for each state variable vector<double> stateNew(numStateVariables); // a single scalar for each state variable // \todo Set up scratch space for material models using getNumScratchVars() and setScratchPtr(). // Create the matParams structure, which is passed to Lament matp->nelements = 1; matp->dt = deltaT; matp->time = 0.0; matp->strain_rate = &strainRate[0]; matp->spin = &spin[0]; matp->deformation_gradient = &defGrad[0]; matp->left_stretch = &leftStretch[0]; matp->rotation = &rotation[0]; matp->state_old = &stateOld[0]; matp->state_new = &stateNew[0]; matp->stress_old = &stressOld[0]; matp->stress_new = &stressNew[0]; // matp->dt_mat = std::numeric_limits<double>::max(); // matParams that still need to be added: // matp->temp_old (temperature) // matp->temp_new // matp->sound_speed_old // matp->sound_speed_new // matp->volume // scratch pointer // function pointers (lots to be done here) for (int cell=0; cell < (int)workset.numCells; ++cell) { for (int qp=0; qp < (int)numQPs; ++qp) { // std::cout << "QP: " << qp << std::endl; // Fill the following entries in matParams for call to LAMENT // // nelements - number of elements // dt - time step, this one is tough because Albany does not currently have a concept of time step for implicit integration // time - current time, again Albany does not currently have a concept of time for implicit integration // strain_rate - what Sierra calls the rate of deformation, it is the symmetric part of the velocity gradient // spin - anti-symmetric part of the velocity gradient // left_stretch - found as V in the polar decomposition of the deformation gradient F = VR // rotation - found as R in the polar decomposition of the deformation gradient F = VR // state_old - material state data for previous time step (material dependent, none for lament::Elastic) // state_new - material state data for current time step (material dependent, none for lament::Elastic) // stress_old - stress at previous time step // stress_new - stress at current time step, filled by material model // // The total deformation gradient is available as field data // // The velocity gradient is not available but can be computed at the logarithm of the incremental deformation gradient divided by deltaT // The incremental deformation gradient is computed as F_new F_old^-1 // JTO: here is how I think this will go (of course the first two lines won't work as is...) // Intrepid2::Tensor<RealType> F = newDefGrad; // Intrepid2::Tensor<RealType> Fn = oldDefGrad; // Intrepid2::Tensor<RealType> f = F*Intrepid2::inverse(Fn); // Intrepid2::Tensor<RealType> V; // Intrepid2::Tensor<RealType> R; // boost::tie(V,R) = Intrepid2::polar_left(F); // Intrepid2::Tensor<RealType> Vinc; // Intrepid2::Tensor<RealType> Rinc; // Intrepid2::Tensor<RealType> logVinc; // boost::tie(Vinc,Rinc,logVinc) = Intrepid2::polar_left_logV(f) // Intrepid2::Tensor<RealType> logRinc = Intrepid2::log_rotation(Rinc); // Intrepid2::Tensor<RealType> logf = Intrepid2::bch(logVinc,logRinc); // Intrepid2::Tensor<RealType> L = (1.0/deltaT)*logf; // Intrepid2::Tensor<RealType> D = Intrepid2::sym(L); // Intrepid2::Tensor<RealType> W = Intrepid2::skew(L); // and then fill data into the vectors below // new deformation gradient (the current deformation gradient as computed in the current configuration) Intrepid2::Tensor<ScalarT> Fnew( 3, defGradField,cell,qp,0,0); // old deformation gradient (deformation gradient at previous load step) Intrepid2::Tensor<ScalarT> Fold( oldDefGrad(cell,qp,0,0), oldDefGrad(cell,qp,0,1), oldDefGrad(cell,qp,0,2), oldDefGrad(cell,qp,1,0), oldDefGrad(cell,qp,1,1), oldDefGrad(cell,qp,1,2), oldDefGrad(cell,qp,2,0), oldDefGrad(cell,qp,2,1), oldDefGrad(cell,qp,2,2) ); // incremental deformation gradient Intrepid2::Tensor<ScalarT> Finc = Fnew * Intrepid2::inverse(Fold); // DEBUGGING // //if(cell==0 && qp==0){ // std::cout << "Fnew(0,0) " << Fnew(0,0) << endl; // std::cout << "Fnew(1,0) " << Fnew(1,0) << endl; // std::cout << "Fnew(2,0) " << Fnew(2,0) << endl; // std::cout << "Fnew(0,1) " << Fnew(0,1) << endl; // std::cout << "Fnew(1,1) " << Fnew(1,1) << endl; // std::cout << "Fnew(2,1) " << Fnew(2,1) << endl; // std::cout << "Fnew(0,2) " << Fnew(0,2) << endl; // std::cout << "Fnew(1,2) " << Fnew(1,2) << endl; // std::cout << "Fnew(2,2) " << Fnew(2,2) << endl; //} // END DEBUGGING // // left stretch V, and rotation R, from left polar decomposition of new deformation gradient Intrepid2::Tensor<ScalarT> V(3), R(3), U(3); boost::tie(V,R) = Intrepid2::polar_left(Fnew); //V = R * U * transpose(R); // DEBUGGING // //if(cell==0 && qp==0){ // std::cout << "U(0,0) " << U(0,0) << endl; // std::cout << "U(1,0) " << U(1,0) << endl; // std::cout << "U(2,0) " << U(2,0) << endl; // std::cout << "U(0,1) " << U(0,1) << endl; // std::cout << "U(1,1) " << U(1,1) << endl; // std::cout << "U(2,1) " << U(2,1) << endl; // std::cout << "U(0,2) " << U(0,2) << endl; // std::cout << "U(1,2) " << U(1,2) << endl; // std::cout << "U(2,2) " << U(2,2) << endl; // std::cout << "========\n"; // std::cout << "V(0,0) " << V(0,0) << endl; // std::cout << "V(1,0) " << V(1,0) << endl; // std::cout << "V(2,0) " << V(2,0) << endl; // std::cout << "V(0,1) " << V(0,1) << endl; // std::cout << "V(1,1) " << V(1,1) << endl; // std::cout << "V(2,1) " << V(2,1) << endl; // std::cout << "V(0,2) " << V(0,2) << endl; // std::cout << "V(1,2) " << V(1,2) << endl; // std::cout << "V(2,2) " << V(2,2) << endl; // std::cout << "========\n"; // std::cout << "R(0,0) " << R(0,0) << endl; // std::cout << "R(1,0) " << R(1,0) << endl; // std::cout << "R(2,0) " << R(2,0) << endl; // std::cout << "R(0,1) " << R(0,1) << endl; // std::cout << "R(1,1) " << R(1,1) << endl; // std::cout << "R(2,1) " << R(2,1) << endl; // std::cout << "R(0,2) " << R(0,2) << endl; // std::cout << "R(1,2) " << R(1,2) << endl; // std::cout << "R(2,2) " << R(2,2) << endl; //} // END DEBUGGING // // incremental left stretch Vinc, incremental rotation Rinc, and log of incremental left stretch, logVinc Intrepid2::Tensor<ScalarT> Uinc(3), Vinc(3), Rinc(3), logVinc(3); //boost::tie(Vinc,Rinc,logVinc) = Intrepid2::polar_left_logV(Finc); boost::tie(Vinc,Rinc) = Intrepid2::polar_left(Finc); //Vinc = Rinc * Uinc * transpose(Rinc); logVinc = Intrepid2::log(Vinc); // log of incremental rotation Intrepid2::Tensor<ScalarT> logRinc = Intrepid2::log_rotation(Rinc); // log of incremental deformation gradient Intrepid2::Tensor<ScalarT> logFinc = Intrepid2::bch(logVinc, logRinc); // velocity gradient Intrepid2::Tensor<ScalarT> L = (1.0/deltaT)*logFinc; // strain rate (a.k.a rate of deformation) Intrepid2::Tensor<ScalarT> D = Intrepid2::sym(L); // spin Intrepid2::Tensor<ScalarT> W = Intrepid2::skew(L); // load everything into the Lament data structure strainRate[0] = ( D(0,0) ); strainRate[1] = ( D(1,1) ); strainRate[2] = ( D(2,2) ); strainRate[3] = ( D(0,1) ); strainRate[4] = ( D(1,2) ); strainRate[5] = ( D(2,0) ); spin[0] = ( W(0,1) ); spin[1] = ( W(1,2) ); spin[2] = ( W(2,0) ); leftStretch[0] = ( V(0,0) ); leftStretch[1] = ( V(1,1) ); leftStretch[2] = ( V(2,2) ); leftStretch[3] = ( V(0,1) ); leftStretch[4] = ( V(1,2) ); leftStretch[5] = ( V(2,0) ); rotation[0] = ( R(0,0) ); rotation[1] = ( R(1,1) ); rotation[2] = ( R(2,2) ); rotation[3] = ( R(0,1) ); rotation[4] = ( R(1,2) ); rotation[5] = ( R(2,0) ); rotation[6] = ( R(1,0) ); rotation[7] = ( R(2,1) ); rotation[8] = ( R(0,2) ); defGrad[0] = ( Fnew(0,0) ); defGrad[1] = ( Fnew(1,1) ); defGrad[2] = ( Fnew(2,2) ); defGrad[3] = ( Fnew(0,1) ); defGrad[4] = ( Fnew(1,2) ); defGrad[5] = ( Fnew(2,0) ); defGrad[6] = ( Fnew(1,0) ); defGrad[7] = ( Fnew(2,1) ); defGrad[8] = ( Fnew(0,2) ); stressOld[0] = oldStress(cell,qp,0,0); stressOld[1] = oldStress(cell,qp,1,1); stressOld[2] = oldStress(cell,qp,2,2); stressOld[3] = oldStress(cell,qp,0,1); stressOld[4] = oldStress(cell,qp,1,2); stressOld[5] = oldStress(cell,qp,2,0); // copy data from the state manager to the LAMENT data structure for(int iVar=0 ; iVar<numStateVariables ; iVar++){ const std::string& variableName = this->lamentMaterialModelStateVariableNames[iVar]+"_old"; Albany::MDArray stateVar = (*workset.stateArrayPtr)[variableName]; stateOld[iVar] = stateVar(cell,qp); } // Make a call to the LAMENT material model to initialize the load step this->lamentMaterialModel->loadStepInit(matp.get()); // Get the stress from the LAMENT material // std::cout << "about to call lament->getStress()" << std::endl; this->lamentMaterialModel->getStress(matp.get()); // std::cout << "after calling lament->getStress() 2" << std::endl; // rotate to get the Cauchy Stress Intrepid2::Tensor<ScalarT> lameStress( stressNew[0], stressNew[3], stressNew[5], stressNew[3], stressNew[1], stressNew[4], stressNew[5], stressNew[4], stressNew[2] ); Intrepid2::Tensor<ScalarT> cauchy = R * lameStress * transpose(R); // DEBUGGING // //if(cell==0 && qp==0){ // std::cout << "check strainRate[0] " << strainRate[0] << endl; // std::cout << "check strainRate[1] " << strainRate[1] << endl; // std::cout << "check strainRate[2] " << strainRate[2] << endl; // std::cout << "check strainRate[3] " << strainRate[3] << endl; // std::cout << "check strainRate[4] " << strainRate[4] << endl; // std::cout << "check strainRate[5] " << strainRate[5] << endl; //} // END DEBUGGING // // Copy the new stress into the stress field for (int i(0); i < 3; ++i) for (int j(0); j < 3; ++j) stressField(cell,qp,i,j) = cauchy(i,j); // stressField(cell,qp,0,0) = stressNew[0]; // stressField(cell,qp,1,1) = stressNew[1]; // stressField(cell,qp,2,2) = stressNew[2]; // stressField(cell,qp,0,1) = stressNew[3]; // stressField(cell,qp,1,2) = stressNew[4]; // stressField(cell,qp,2,0) = stressNew[5]; // stressField(cell,qp,1,0) = stressNew[3]; // stressField(cell,qp,2,1) = stressNew[4]; // stressField(cell,qp,0,2) = stressNew[5]; // copy state_new data from the LAMENT data structure to the corresponding state variable field for(int iVar=0 ; iVar<numStateVariables ; iVar++) this->lamentMaterialModelStateVariableFields[iVar](cell,qp) = stateNew[iVar]; // DEBUGGING // //if(cell==0 && qp==0){ // std::cout << "stress(0,0) " << this->stressField(cell,qp,0,0) << endl; // std::cout << "stress(1,1) " << this->stressField(cell,qp,1,1) << endl; // std::cout << "stress(2,2) " << this->stressField(cell,qp,2,2) << endl; // std::cout << "stress(0,1) " << this->stressField(cell,qp,0,1) << endl; // std::cout << "stress(1,2) " << this->stressField(cell,qp,1,2) << endl; // std::cout << "stress(0,2) " << this->stressField(cell,qp,0,2) << endl; // std::cout << "stress(1,0) " << this->stressField(cell,qp,1,0) << endl; // std::cout << "stress(2,1) " << this->stressField(cell,qp,2,1) << endl; // std::cout << "stress(2,0) " << this->stressField(cell,qp,2,0) << endl; // //} // // END DEBUGGING // } } }
inline U get(types<T>, lua_State* L, int index = -1) { return U(L, index); }
Error Is::initInternal(const ConfigSet& config) { m_maxLightIds = config.getNumber("is.maxLightsPerCluster"); if(m_maxLightIds == 0) { ANKI_LOGE("Incorrect number of max light indices"); return ErrorCode::USER_DATA; } m_rtMipCount = computeMaxMipmapCount2d(m_r->getWidth(), m_r->getHeight(), 32); ANKI_ASSERT(m_rtMipCount); U clusterCount = m_r->getTileCountXY().x() * m_r->getTileCountXY().y() * config.getNumber("clusterSizeZ"); m_clusterCount = clusterCount; m_maxLightIds *= clusterCount; m_lightBin = getAllocator().newInstance<LightBin>(getAllocator(), m_r->getTileCountXY().x(), m_r->getTileCountXY().y(), config.getNumber("clusterSizeZ"), &m_r->getThreadPool(), &getGrManager()); // // Load the programs // StringAuto pps(getAllocator()); pps.sprintf("\n#define TILE_COUNT_X %u\n" "#define TILE_COUNT_Y %u\n" "#define CLUSTER_COUNT %u\n" "#define RENDERER_WIDTH %u\n" "#define RENDERER_HEIGHT %u\n" "#define MAX_LIGHT_INDICES %u\n" "#define POISSON %u\n" "#define INDIRECT_ENABLED %u\n" "#define IR_MIPMAP_COUNT %u\n", m_r->getTileCountXY().x(), m_r->getTileCountXY().y(), clusterCount, m_r->getWidth(), m_r->getHeight(), m_maxLightIds, m_r->getSm().getPoissonEnabled(), 1, m_r->getIr().getReflectionTextureMipmapCount()); // point light ANKI_CHECK(getResourceManager().loadResourceToCache(m_lightVert, "shaders/Is.vert.glsl", pps.toCString(), "r_")); ANKI_CHECK(getResourceManager().loadResourceToCache(m_lightFrag, "shaders/Is.frag.glsl", pps.toCString(), "r_")); PipelineInitInfo init; init.m_inputAssembler.m_topology = PrimitiveTopology::TRIANGLE_STRIP; init.m_depthStencil.m_depthWriteEnabled = false; init.m_depthStencil.m_depthCompareFunction = CompareOperation::ALWAYS; init.m_color.m_attachmentCount = 1; init.m_color.m_attachments[0].m_format = IS_COLOR_ATTACHMENT_PIXEL_FORMAT; init.m_shaders[U(ShaderType::VERTEX)] = m_lightVert->getGrShader(); init.m_shaders[U(ShaderType::FRAGMENT)] = m_lightFrag->getGrShader(); m_lightPpline = getGrManager().newInstance<Pipeline>(init); // // Create framebuffer // m_r->createRenderTarget(m_r->getWidth(), m_r->getHeight(), IS_COLOR_ATTACHMENT_PIXEL_FORMAT, TextureUsageBit::SAMPLED_FRAGMENT | TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE | TextureUsageBit::SAMPLED_COMPUTE, SamplingFilter::LINEAR, m_rtMipCount, m_rt); FramebufferInitInfo fbInit; fbInit.m_colorAttachmentCount = 1; fbInit.m_colorAttachments[0].m_texture = m_rt; fbInit.m_colorAttachments[0].m_loadOperation = AttachmentLoadOperation::DONT_CARE; fbInit.m_colorAttachments[0].m_usageInsideRenderPass = TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE; m_fb = getGrManager().newInstance<Framebuffer>(fbInit); // // Create resource group // { ResourceGroupInitInfo init; init.m_textures[0].m_texture = m_r->getMs().m_rt0; init.m_textures[1].m_texture = m_r->getMs().m_rt1; init.m_textures[2].m_texture = m_r->getMs().m_rt2; init.m_textures[3].m_texture = m_r->getMs().m_depthRt; init.m_textures[3].m_usage = TextureUsageBit::SAMPLED_FRAGMENT | TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ; init.m_textures[4].m_texture = m_r->getSm().getSpotTextureArray(); init.m_textures[5].m_texture = m_r->getSm().getOmniTextureArray(); init.m_textures[6].m_texture = m_r->getIr().getReflectionTexture(); init.m_textures[7].m_texture = m_r->getIr().getIrradianceTexture(); init.m_textures[8].m_texture = m_r->getIr().getIntegrationLut(); init.m_textures[8].m_sampler = m_r->getIr().getIntegrationLutSampler(); init.m_uniformBuffers[0].m_uploadedMemory = true; init.m_uniformBuffers[0].m_usage = BufferUsageBit::UNIFORM_FRAGMENT | BufferUsageBit::UNIFORM_VERTEX; init.m_uniformBuffers[1].m_uploadedMemory = true; init.m_uniformBuffers[1].m_usage = BufferUsageBit::UNIFORM_FRAGMENT | BufferUsageBit::UNIFORM_VERTEX; init.m_uniformBuffers[2].m_uploadedMemory = true; init.m_uniformBuffers[2].m_usage = BufferUsageBit::UNIFORM_FRAGMENT | BufferUsageBit::UNIFORM_VERTEX; init.m_uniformBuffers[3].m_uploadedMemory = true; init.m_uniformBuffers[3].m_usage = BufferUsageBit::UNIFORM_FRAGMENT | BufferUsageBit::UNIFORM_VERTEX; init.m_uniformBuffers[4].m_uploadedMemory = true; init.m_uniformBuffers[4].m_usage = BufferUsageBit::UNIFORM_FRAGMENT | BufferUsageBit::UNIFORM_VERTEX; init.m_storageBuffers[0].m_uploadedMemory = true; init.m_storageBuffers[0].m_usage = BufferUsageBit::STORAGE_FRAGMENT_READ | BufferUsageBit::STORAGE_VERTEX_READ; init.m_storageBuffers[1].m_uploadedMemory = true; init.m_storageBuffers[1].m_usage = BufferUsageBit::STORAGE_FRAGMENT_READ | BufferUsageBit::STORAGE_VERTEX_READ; m_rcGroup = getGrManager().newInstance<ResourceGroup>(init); } TextureInitInfo texinit; texinit.m_width = texinit.m_height = 4; texinit.m_usage = TextureUsageBit::SAMPLED_FRAGMENT; texinit.m_format = PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM); m_dummyTex = getGrManager().newInstance<Texture>(texinit); return ErrorCode::NONE; }
void macro_U_Test() { (void)U(); }
X2( U = U()) { }
static U value() { return U(Nom) / U(Denom); };
/* Subroutine */ int dlarnv_slu(integer *idist, integer *iseed, integer *n, doublereal *x) { /* -- LAPACK auxiliary routine (version 2.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University September 30, 1994 Purpose ======= DLARNV returns a vector of n random real numbers from a uniform or normal distribution. Arguments ========= IDIST (input) INTEGER Specifies the distribution of the random numbers: = 1: uniform (0,1) = 2: uniform (-1,1) = 3: normal (0,1) ISEED (input/output) INTEGER array, dimension (4) On entry, the seed of the random number generator; the array elements must be between 0 and 4095, and ISEED(4) must be odd. On exit, the seed is updated. N (input) INTEGER The number of random numbers to be generated. X (output) DOUBLE PRECISION array, dimension (N) The generated random numbers. Further Details =============== This routine calls the auxiliary routine DLARUV to generate random real numbers from a uniform (0,1) distribution, in batches of up to 128 using vectorisable code. The Box-Muller method is used to transform numbers from a uniform to a normal distribution. ===================================================================== Parameter adjustments Function Body */ /* System generated locals */ integer i__1, i__2, i__3; /* Builtin functions */ double log(doublereal), sqrt(doublereal), cos(doublereal); /* Local variables */ static integer i; static doublereal u[128]; static integer il, iv; extern /* Subroutine */ int dlaruv_slu(integer *, integer *, doublereal *); static integer il2; #define U(I) u[(I)] #define X(I) x[(I)-1] #define ISEED(I) iseed[(I)-1] i__1 = *n; for (iv = 1; iv <= *n; iv += 64) { /* Computing MIN */ i__2 = 64, i__3 = *n - iv + 1; il = min(i__2,i__3); if (*idist == 3) { il2 = il << 1; } else { il2 = il; } /* Call DLARUV to generate IL2 numbers from a uniform (0,1) distribution (IL2 <= LV) */ dlaruv_slu(&ISEED(1), &il2, u); if (*idist == 1) { /* Copy generated numbers */ i__2 = il; for (i = 1; i <= il; ++i) { X(iv + i - 1) = U(i - 1); /* L10: */ } } else if (*idist == 2) { /* Convert generated numbers to uniform (-1,1) distribut ion */ i__2 = il; for (i = 1; i <= il; ++i) { X(iv + i - 1) = U(i - 1) * 2. - 1.; /* L20: */ } } else if (*idist == 3) { /* Convert generated numbers to normal (0,1) distributio n */ i__2 = il; for (i = 1; i <= il; ++i) { X(iv + i - 1) = sqrt(log(U((i << 1) - 2)) * -2.) * cos(U((i << 1) - 1) * 6.2831853071795864769252867663); /* L30: */ } } /* L40: */ } return 0; /* End of DLARNV */ } /* dlarnv_slu */
} head->m_depth = newDepth; // FIXME: If the width and height of the quotation characters does not change we may only need to // Invalidate the renderer's area not a relayout. head->setNeedsLayoutAndPrefWidthsRecalc(); head = head->m_next; if (head == tail) // We are at the splicing point tail = 0; // Mark the possible depth discontinuity fixed. } while (head); } #define ARRAY_SIZE(Carray) (sizeof(Carray) / sizeof(*Carray)) #define LANGUAGE_DATA(name, languageSourceArray) { name, languageSourceArray, ARRAY_SIZE(languageSourceArray) } #define U(x) ((const UChar*)L##x) static const UChar* simpleQuotes[] = {U("\""), U("\""), U("'"), U("'")}; static const UChar* englishQuotes[] = {U("\x201C"), U("\x201D"), U("\x2018"), U("\x2019")}; static const UChar* norwegianQuotes[] = { U("\x00AB"), U("\x00BB"), U("\x2039"), U("\x203A") }; static const UChar* romanianQuotes[] = { U("\x201E"), U("\x201D")}; static const UChar* russianQuotes[] = { U("\x00AB"), U("\x00BB"), U("\x201E"), U("\x201C") }; #undef U struct LanguageData { const char *name; const UChar* const* const array; const int arraySize; bool operator<(const LanguageData& compareTo) const { return strcmp(name, compareTo.name); }
static void test_register_filter_with_null_clsMinorType(void) { IFilterMapper2 *pMapper = NULL; HRESULT hr; REGFILTER2 rgf2; REGFILTERPINS rgPins; REGFILTERPINS2 rgPins2; REGPINTYPES rgPinType; static WCHAR wszPinName[] = {'P', 'i', 'n', 0 }; static const WCHAR wszFilterName1[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '1', 0 }; static const WCHAR wszFilterName2[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '2', 0 }; CLSID clsidFilter1; CLSID clsidFilter2; hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pMapper); ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr); if (FAILED(hr)) goto out; hr = CoCreateGuid(&clsidFilter1); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); hr = CoCreateGuid(&clsidFilter2); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); rgPinType.clsMajorType = &GUID_NULL; /* Make sure quartz accepts it without crashing */ rgPinType.clsMinorType = NULL; /* Test with pin descript version 1 */ ZeroMemory(&rgf2, sizeof(rgf2)); rgf2.dwVersion = 1; rgf2.dwMerit = MERIT_UNLIKELY; S1(U(rgf2)).cPins = 1; S1(U(rgf2)).rgPins = &rgPins; rgPins.strName = wszPinName; rgPins.bRendered = 1; rgPins.bOutput = 0; rgPins.bZero = 0; rgPins.bMany = 0; rgPins.clsConnectsToFilter = NULL; rgPins.strConnectsToPin = NULL; rgPins.nMediaTypes = 1; rgPins.lpMediaType = &rgPinType; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, wszFilterName1, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); if (hr == E_ACCESSDENIED) { skip("Not authorized to register filters\n"); goto out; } ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter1); ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr); /* Test with pin descript version 2 */ ZeroMemory(&rgf2, sizeof(rgf2)); rgf2.dwVersion = 2; rgf2.dwMerit = MERIT_UNLIKELY; S2(U(rgf2)).cPins2 = 1; S2(U(rgf2)).rgPins2 = &rgPins2; rgPins2.dwFlags = REG_PINFLAG_B_RENDERER; rgPins2.cInstances = 1; rgPins2.nMediaTypes = 1; rgPins2.lpMediaType = &rgPinType; rgPins2.nMediums = 0; rgPins2.lpMedium = NULL; rgPins2.clsPinCategory = NULL; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, wszFilterName2, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter2); ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr); out: if (pMapper) IFilterMapper2_Release(pMapper); }
int main(int argc, char *argv[]) { timeSelector::addOptions(); # include "setRootCase.H" # include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; IOobject pheader ( "p", runTime.timeName(), mesh, IOobject::MUST_READ ); IOobject Uheader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); // Check p and U exist if (pheader.headerOk() && Uheader.headerOk()) { mesh.readUpdate(); Info<< " Reading p" << endl; volScalarField p(pheader, mesh); Info<< " Reading U" << endl; volVectorField U(Uheader, mesh); Info<< " Calculating ptot" << endl; if (p.dimensions() == dimensionSet(0, 2, -2, 0, 0)) { volScalarField ptot ( IOobject ( "ptot", runTime.timeName(), mesh, IOobject::NO_READ ), p + 0.5*magSqr(U) ); ptot.write(); } else { IOobject rhoheader ( "rho", runTime.timeName(), mesh, IOobject::MUST_READ ); // Check rho exists if (rhoheader.headerOk()) { Info<< " Reading rho" << endl; volScalarField rho(rhoheader, mesh); volScalarField ptot ( IOobject ( "ptot", runTime.timeName(), mesh, IOobject::NO_READ ), p + 0.5*rho*magSqr(U) ); ptot.write(); } else { Info<< " No rho" << endl; } } } else { Info<< " No p or U" << endl; } Info<< endl; }
static void test_fm2_enummatchingfilters(void) { IFilterMapper2 *pMapper = NULL; HRESULT hr; REGFILTER2 rgf2; REGFILTERPINS2 rgPins2[2]; REGPINTYPES rgPinType; static const WCHAR wszFilterName1[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '1', 0 }; static const WCHAR wszFilterName2[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '2', 0 }; CLSID clsidFilter1; CLSID clsidFilter2; IEnumMoniker *pEnum = NULL; BOOL found; ZeroMemory(&rgf2, sizeof(rgf2)); hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pMapper); ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr); if (FAILED(hr)) goto out; hr = CoCreateGuid(&clsidFilter1); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); hr = CoCreateGuid(&clsidFilter2); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); /* Test that a test renderer filter is returned when enumerating filters with bRender=FALSE */ rgf2.dwVersion = 2; rgf2.dwMerit = MERIT_UNLIKELY; S2(U(rgf2)).cPins2 = 1; S2(U(rgf2)).rgPins2 = rgPins2; rgPins2[0].dwFlags = REG_PINFLAG_B_RENDERER; rgPins2[0].cInstances = 1; rgPins2[0].nMediaTypes = 1; rgPins2[0].lpMediaType = &rgPinType; rgPins2[0].nMediums = 0; rgPins2[0].lpMedium = NULL; rgPins2[0].clsPinCategory = NULL; rgPinType.clsMajorType = &GUID_NULL; rgPinType.clsMinorType = &GUID_NULL; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, wszFilterName1, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); if (hr == E_ACCESSDENIED) skip("Not authorized to register filters\n"); else { ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); rgPins2[0].dwFlags = 0; rgPins2[1].dwFlags = REG_PINFLAG_B_OUTPUT; rgPins2[1].cInstances = 1; rgPins2[1].nMediaTypes = 1; rgPins2[1].lpMediaType = &rgPinType; rgPins2[1].nMediums = 0; rgPins2[1].lpMedium = NULL; rgPins2[1].clsPinCategory = NULL; S2(U(rgf2)).cPins2 = 2; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, wszFilterName2, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, FALSE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName1, pEnum); ok(found, "EnumMatchingFilters failed to return the test filter 1\n"); } if (pEnum) IEnumMoniker_Release(pEnum); pEnum = NULL; hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, FALSE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName2, pEnum); ok(found, "EnumMatchingFilters failed to return the test filter 2\n"); } if (pEnum) IEnumMoniker_Release(pEnum); pEnum = NULL; /* Non renderer must not be returned with bRender=TRUE */ hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName1, pEnum); ok(found, "EnumMatchingFilters failed to return the test filter 1\n"); } } if (pEnum) IEnumMoniker_Release(pEnum); pEnum = NULL; hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName2, pEnum); ok(!found, "EnumMatchingFilters should not return the test filter 2\n"); } hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter1); ok(SUCCEEDED(hr), "IFilterMapper2_UnregisterFilter failed with %x\n", hr); hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter2); ok(SUCCEEDED(hr), "IFilterMapper2_UnregisterFilter failed with %x\n", hr); out: if (pEnum) IEnumMoniker_Release(pEnum); if (pMapper) IFilterMapper2_Release(pMapper); }
inline Eigen::MatrixXd randomCovarianceXd(int N) { Eigen::MatrixXd U(N,N); U.setRandom(); return U.transpose() * U + 5.0 * Eigen::MatrixXd::Identity(N,N); }
static Py_ssize_t rjsmin(const rchar *source, rchar *target, Py_ssize_t length, int keep_bang_comments) { const rchar *reset, *pcreset = NULL, *pctoken = NULL, *xtarget, *sentinel = source + length; rchar *tstart = target; int post_regex = 0; rchar c, quote, spaced = U(' '); while (source < sentinel) { c = *source++; if (RJSMIN_IS_DULL(c)) { if (post_regex) post_regex = 0; if (pctoken) pctoken = NULL; if (spaced == U('\n')) spaced = U(' '); *target++ = c; continue; } switch (c) { /* String */ case U('\''): case U('"'): if (post_regex) post_regex = 0; if (pctoken) pctoken = NULL; if (spaced == U('\n')) spaced = U(' '); reset = source; *target++ = quote = c; while (source < sentinel) { c = *source++; *target++ = c; if (RJSMIN_IS_STRING_DULL(c)) continue; switch (c) { case U('\''): case U('"'): if (c == quote) goto cont; continue; case U('\\'): if (source < sentinel) { c = *source++; *target++ = c; if (c == U('\r') && source < sentinel && *source == U('\n')) *target++ = *source++; } continue; } break; } target -= source - reset; source = reset; continue; /* Comment or Regex or something else entirely */ case U('/'): if (!(source < sentinel)) { if (post_regex) post_regex = 0; if (pctoken) pctoken = NULL; if (spaced == U('\n')) spaced = U(' '); *target++ = c; } else { switch (*source) { /* Comment */ case U('*'): case U('/'): goto skip_or_copy_ws; default: xtarget = NULL; if ( target == tstart || RJSMIN_IS_PRE_REGEX_1(*((pctoken ? pctoken : target) - 1)) || ( (xtarget = pctoken ? pctoken : target) && (xtarget - tstart >= 6) && *(xtarget - 1) == U('n') && *(xtarget - 2) == U('r') && *(xtarget - 3) == U('u') && *(xtarget - 4) == U('t') && *(xtarget - 5) == U('e') && *(xtarget - 6) == U('r') && ( xtarget - tstart == 6 || !RJSMIN_IS_ID_LITERAL(*(xtarget - 7)) ) )) { /* Regex */ if (post_regex) post_regex = 0; if (pctoken) pctoken = NULL; reset = source; if (spaced == U('\n')) { spaced = U(' '); if (xtarget) *target++ = U('\n'); } *target++ = U('/'); while (source < sentinel) { c = *source++; *target++ = c; if (RJSMIN_IS_REGEX_DULL(c)) continue; switch (c) { case U('/'): post_regex = 1; goto cont; case U('\\'): if (source < sentinel) { c = *source++; *target++ = c; if (c == U('\r') || c == U('\n')) break; } continue; case U('['): while (source < sentinel) { c = *source++; *target++ = c; if (RJSMIN_IS_REGEX_CC_DULL(c)) continue; switch (c) { case U('\\'): if (source < sentinel) { c = *source++; *target++ = c; if (c == U('\r') || c == U('\n')) break; } continue; case U(']'): goto cont_regex; } } break; } break; cont_regex: continue; } target -= source - reset; source = reset; } else { /* Just a slash */ if (post_regex) post_regex = 0; if (pctoken) pctoken = NULL; if (spaced == U('\n')) spaced = U(' '); *target++ = c; } continue; } } continue; /* Whitespace */ default: skip_or_copy_ws: quote = U(' '); --source; while (source < sentinel) { c = *source++; if (RJSMIN_IS_SPACE(c)) continue; switch (c) { case U('\r'): case U('\n'): quote = U('\n'); continue; case U('/'): if (source < sentinel) { switch (*source) { case U('*'): reset = source++; /* copy bang comment, if requested */ if ( keep_bang_comments && source < sentinel && *source == U('!')) { if (!pctoken) { pctoken = target; pcreset = reset; } *target++ = U('/'); *target++ = U('*'); *target++ = *source++; while (source < sentinel) { c = *source++; *target++ = c; if (c == U('*') && source < sentinel && *source == U('/')) { *target++ = *source++; reset = NULL; break; } } if (!reset) continue; target -= source - reset; source = reset; if (pcreset == reset) { pctoken = NULL; pcreset = NULL; } } /* strip regular comment */ else { while (source < sentinel) { c = *source++; if (c == U('*') && source < sentinel && *source == U('/')) { ++source; reset = NULL; break; } } if (!reset) continue; source = reset; *target++ = U('/'); } goto cont; case U('/'): ++source; while (source < sentinel) { c = *source++; switch (c) { case U('\n'): break; case U('\r'): if (source < sentinel && *source == U('\n')) ++source; break; default: continue; } break; } quote = U('\n'); continue; } } } --source; break; } if ((tstart < (pctoken ? pctoken : target) && source < sentinel) && ((quote == U('\n') && ((RJSMIN_IS_ID_LITERAL_CLOSE(*((pctoken ? pctoken : target) - 1)) && RJSMIN_IS_ID_LITERAL_OPEN(*source)) || (post_regex && RJSMIN_IS_POST_REGEX_OFF(*source) && !(post_regex = 0)))) || (quote == U(' ') && !pctoken && ((RJSMIN_IS_ID_LITERAL(*(target - 1)) && RJSMIN_IS_ID_LITERAL(*source)) || (source < sentinel && ((*(target - 1) == U('+') && *source == U('+')) || (*(target - 1) == U('-') && *source == U('-')))))))) { *target++ = quote; } pcreset = NULL; spaced = quote; } cont: continue; } return (Py_ssize_t)(target - tstart); }
void VelocityPenaltyAdjointStabilization<Mu>::element_time_derivative( bool compute_jacobian, AssemblyContext& context, CachedValues& /*cache*/ ) { #ifdef GRINS_USE_GRVY_TIMERS this->_timer->BeginTimer("VelocityPenaltyAdjointStabilization::element_time_derivative"); #endif // The number of local degrees of freedom in each variable. const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size(); // Element Jacobian * quadrature weights for interior integration. const std::vector<libMesh::Real> &JxW = context.get_element_fe(this->_flow_vars.u())->get_JxW(); const std::vector<libMesh::Point>& u_qpoint = context.get_element_fe(this->_flow_vars.u())->get_xyz(); const std::vector<std::vector<libMesh::Real> >& u_phi = context.get_element_fe(this->_flow_vars.u())->get_phi(); const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi = context.get_element_fe(this->_flow_vars.u())->get_dphi(); const std::vector<std::vector<libMesh::RealTensor> >& u_hessphi = context.get_element_fe(this->_flow_vars.u())->get_d2phi(); // Get residuals and jacobians libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u()); // R_{u} libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v()); // R_{v} libMesh::DenseSubVector<libMesh::Number> *Fw = NULL; libMesh::DenseSubMatrix<libMesh::Number> &Kuu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u()); // J_{uu} libMesh::DenseSubMatrix<libMesh::Number> &Kuv = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.v()); // J_{uv} libMesh::DenseSubMatrix<libMesh::Number> &Kvu = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.u()); // J_{vu} libMesh::DenseSubMatrix<libMesh::Number> &Kvv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v()); // J_{vv} libMesh::DenseSubMatrix<libMesh::Number> *Kuw = NULL; libMesh::DenseSubMatrix<libMesh::Number> *Kvw = NULL; libMesh::DenseSubMatrix<libMesh::Number> *Kwu = NULL; libMesh::DenseSubMatrix<libMesh::Number> *Kwv = NULL; libMesh::DenseSubMatrix<libMesh::Number> *Kww = NULL; if(this->mesh_dim(context) == 3) { Fw = &context.get_elem_residual(this->_flow_vars.w()); // R_{w} Kuw = &context.get_elem_jacobian (this->_flow_vars.u(), this->_flow_vars.w()); // J_{uw} Kvw = &context.get_elem_jacobian (this->_flow_vars.v(), this->_flow_vars.w()); // J_{vw} Kwu = &context.get_elem_jacobian (this->_flow_vars.w(), this->_flow_vars.u()); // J_{wu} Kwv = &context.get_elem_jacobian (this->_flow_vars.w(), this->_flow_vars.v()); // J_{wv} Kww = &context.get_elem_jacobian (this->_flow_vars.w(), this->_flow_vars.w()); // J_{ww} } // Now we will build the element Jacobian and residual. // Constructing the residual requires the solution and its // gradient from the previous timestep. This must be // calculated at each quadrature point by summing the // solution degree-of-freedom values by the appropriate // weight functions. unsigned int n_qpoints = context.get_element_qrule().n_points(); libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u()); for (unsigned int qp=0; qp != n_qpoints; qp++) { libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp ); libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp ); libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ), context.interior_value( this->_flow_vars.v(), qp ) ); if( this->mesh_dim(context) == 3 ) { U(2) = context.interior_value( this->_flow_vars.w(), qp ); } // Compute the viscosity at this qp libMesh::Real mu_qp = this->_mu(context, qp); libMesh::Real tau_M; libMesh::Real d_tau_M_d_rho; libMesh::Gradient d_tau_M_dU; if (compute_jacobian) this->_stab_helper.compute_tau_momentum_and_derivs ( context, qp, g, G, this->_rho, U, mu_qp, tau_M, d_tau_M_d_rho, d_tau_M_dU, this->_is_steady ); else tau_M = this->_stab_helper.compute_tau_momentum ( context, qp, g, G, this->_rho, U, mu_qp, this->_is_steady ); libMesh::NumberVectorValue F; libMesh::NumberTensorValue dFdU; libMesh::NumberTensorValue* dFdU_ptr = compute_jacobian ? &dFdU : NULL; if (!this->compute_force(u_qpoint[qp], context, U, F, dFdU_ptr)) continue; for (unsigned int i=0; i != n_u_dofs; i++) { libMesh::Real test_func = this->_rho*U*u_gradphi[i][qp] + mu_qp*( u_hessphi[i][qp](0,0) + u_hessphi[i][qp](1,1) + u_hessphi[i][qp](2,2) ); Fu(i) += tau_M*F(0)*test_func*JxW[qp]; Fv(i) += tau_M*F(1)*test_func*JxW[qp]; if (this->mesh_dim(context) == 3) { (*Fw)(i) += tau_M*F(2)*test_func*JxW[qp]; } if (compute_jacobian) { libMesh::Gradient d_test_func_dU = this->_rho*u_gradphi[i][qp]; for (unsigned int j=0; j != n_u_dofs; ++j) { Kuu(i,j) += tau_M*F(0)*d_test_func_dU(0)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); Kuu(i,j) += d_tau_M_dU(0)*u_phi[j][qp]*F(0)*test_func*JxW[qp]*context.get_elem_solution_derivative(); Kuu(i,j) += tau_M*dFdU(0,0)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); Kuv(i,j) += tau_M*F(0)*d_test_func_dU(1)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); Kuv(i,j) += d_tau_M_dU(1)*u_phi[j][qp]*F(0)*test_func*JxW[qp]*context.get_elem_solution_derivative(); Kuv(i,j) += tau_M*dFdU(0,1)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); Kvu(i,j) += tau_M*F(1)*d_test_func_dU(0)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); Kvu(i,j) += d_tau_M_dU(0)*u_phi[j][qp]*F(1)*test_func*JxW[qp]*context.get_elem_solution_derivative(); Kvu(i,j) += tau_M*dFdU(1,0)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); Kvv(i,j) += tau_M*F(1)*d_test_func_dU(1)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); Kvv(i,j) += d_tau_M_dU(1)*u_phi[j][qp]*F(1)*test_func*JxW[qp]*context.get_elem_solution_derivative(); Kvv(i,j) += tau_M*dFdU(1,1)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); } if (this->mesh_dim(context) == 3) { for (unsigned int j=0; j != n_u_dofs; ++j) { (*Kuw)(i,j) += tau_M*F(0)*d_test_func_dU(2)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); (*Kuw)(i,j) += d_tau_M_dU(2)*u_phi[j][qp]*F(0)*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kuw)(i,j) += tau_M*dFdU(0,2)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kvw)(i,j) += tau_M*F(1)*d_test_func_dU(2)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); (*Kvw)(i,j) += d_tau_M_dU(2)*u_phi[j][qp]*F(1)*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kvw)(i,j) += tau_M*dFdU(1,2)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kwu)(i,j) += tau_M*F(2)*d_test_func_dU(0)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); (*Kwu)(i,j) += d_tau_M_dU(0)*u_phi[j][qp]*F(2)*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kwu)(i,j) += tau_M*dFdU(2,0)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kwv)(i,j) += tau_M*F(2)*d_test_func_dU(1)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); (*Kwv)(i,j) += d_tau_M_dU(1)*u_phi[j][qp]*F(2)*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kwv)(i,j) += tau_M*dFdU(2,1)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kww)(i,j) += tau_M*F(2)*d_test_func_dU(2)*u_phi[j][qp]*JxW[qp]*context.get_elem_solution_derivative(); (*Kww)(i,j) += d_tau_M_dU(2)*u_phi[j][qp]*F(2)*test_func*JxW[qp]*context.get_elem_solution_derivative(); (*Kww)(i,j) += tau_M*dFdU(2,2)*u_phi[j][qp]*test_func*JxW[qp]*context.get_elem_solution_derivative(); } } } // End compute_jacobian check } // End i dof loop } // End quadrature loop #ifdef GRINS_USE_GRVY_TIMERS this->_timer->EndTimer("BoussinesqBuoyancyAdjointStabilization::element_time_derivative"); #endif return; }
int main(int argc, char *argv[]) { timeSelector::addOptions(); #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); #include "createMesh.H" Kmesh K(mesh); runTime.setTime(timeDirs.last(), timeDirs.size()-1); forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; IOobject pheader ( "p", runTime.timeName(), mesh, IOobject::MUST_READ ); if (!pheader.headerOk()) { Info << "Unable to read p" << endl; return EXIT_FAILURE; } Info << " Reading p" << endl; volScalarField p(pheader, mesh); IOobject Uheader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); if (!Uheader.headerOk()) { Info << "Unable to read U" << endl; return EXIT_FAILURE; } Info << " Reading U" << endl; volVectorField U(Uheader, mesh); { calcEk(U, K).write ( runTime.path()/"graphs"/runTime.timeName(), "Ek", runTime.graphFormat() ); } Info<< endl; }
pplx::task<std::vector<std::pair<std::time_t, Chat>>> NiconicoJikkyouLogChatProvider::CollectChat(int jkId, const std::chrono::system_clock::time_point &startTime, const std::chrono::system_clock::time_point &endTime, int resFrom) { web::http::client::http_client_config clientConfig; clientConfig.set_timeout(std::chrono::seconds(10)); web::http::client::http_client client(U("http://jk.nicovideo.jp"),clientConfig); web::http::http_request req; std::string cookie = this->login->GetUserSessionCookie(); utility::string_t endTimeStr = utility::conversions::print_string(std::chrono::system_clock::to_time_t(endTime)); req.headers().add(U("Cookie"), cookie.c_str()); req.set_request_uri(U("/api/getflv?v=jk") + utility::conversions::print_string(jkId) + U("&start_time=") + utility::conversions::print_string(std::chrono::system_clock::to_time_t(startTime)) + U("&end_time=") + endTimeStr); return client.request(req).then([endTimeStr, resFrom, cookie = std::move(cookie),clientConfig=std::move(clientConfig)](web::http::http_response &response) { //非同期実行部分 auto query = web::uri::split_query(response.extract_string().get()); if (query.count(U("error"))) { throw std::runtime_error("failed to download"); //this->login->Relogin(); //return; } utility::string_t thread_id = query[U("thread_id")]; utility::string_t ms = query[U("ms")]; utility::string_t http_port = query[U("http_port")]; utility::string_t user_id = query[U("user_id")]; web::http::http_request req; req.headers().add(U("Cookie"), cookie.c_str()); web::http::client::http_client client(U("http://jk.nicovideo.jp"), clientConfig); req.set_request_uri(U("/api/v2/getwaybackkey?thread=") + thread_id); web::http::http_response res = client.request(req).get(); utility::string_t waybackKey = res.extract_string().get(); waybackKey = waybackKey.substr(waybackKey.find('=') + 1); web::http::client::http_client cli(U("http://") + ms + U(":") + http_port, clientConfig); req.set_request_uri(U("/api/thread?thread=") + thread_id + U("&res_from=")+utility::conversions::print_string(resFrom)+ U("&version=20061206&when=") + endTimeStr + U("&user_id=") + user_id + U("&waybackkey=") + waybackKey + U("&scores=1")); std::vector<unsigned char> data = cli.request(req).get().extract_vector().get(); NiconicoJikkyouXmlParser parser; parser.PushString(std::string((char*)data.data(), data.size())); std::vector<std::pair<std::time_t, Chat>> ret; while (parser.HasChat()) { auto pair = parser.PopChat(); ret.emplace_back(pair.first, pair.second); } return ret; }); }
void HandleJson::EndJob(json::value jsonObj) { int jobId = jsonObj.at(U("JobId")).as_integer(); JobTaskDb::GetInstance().EndJob(jobId); }