void ComputeInitialConditionThread::operator() (const ConstElemRange & range) { ParallelUniqueId puid; _tid = puid.id; const InitialConditionWarehouse & warehouse = _fe_problem.getInitialConditionWarehouse(); // Iterate over all the elements in the range for (ConstElemRange::const_iterator elem_it=range.begin(); elem_it != range.end(); ++elem_it) { const Elem* elem = *elem_it; SubdomainID subdomain = elem->subdomain_id(); _fe_problem.prepare(elem, _tid); if (warehouse.hasActiveBlockObjects(subdomain, _tid)) { const std::vector<MooseSharedPointer<InitialCondition> > & ics = warehouse.getActiveBlockObjects(subdomain, _tid); for (std::vector<MooseSharedPointer<InitialCondition> >::const_iterator it = ics.begin(); it != ics.end(); ++it) (*it)->compute(); } } }
void MaxQpsThread::operator() (const ConstElemRange & range) { ParallelUniqueId puid; _tid = puid.id; // For short circuiting reinit std::set<ElemType> seen_it; for (ConstElemRange::const_iterator elem_it = range.begin() ; elem_it != range.end(); ++elem_it) { const Elem * elem = *elem_it; // Only reinit if the element type has not previously been seen if (seen_it.insert(elem->type()).second) { FEType fe_type(FIRST, LAGRANGE); unsigned int dim = elem->dim(); unsigned int side = 0; // we assume that any element will have at least one side ;) // We cannot mess with the FE objects in Assembly, because we might need to request second derivatives // later on. If we used them, we'd call reinit on them, thus making the call to request second // derivatives harmful (i.e. leading to segfaults/asserts). Thus, we have to use a locally allocated object here. FEBase * fe = FEBase::build(dim, fe_type).release(); // figure out the number of qps for volume QBase * qrule = QBase::build(_qtype, dim, _order).release(); fe->attach_quadrature_rule(qrule); fe->reinit(elem); if (qrule->n_points() > _max) _max = qrule->n_points(); delete qrule; // figure out the number of qps for the face // NOTE: user might specify higher order rule for faces, thus possibly ending up with more qps than in the volume QBase * qrule_face = QBase::build(_qtype, dim - 1, _face_order).release(); fe->attach_quadrature_rule(qrule_face); fe->reinit(elem, side); if (qrule_face->n_points() > _max) _max = qrule_face->n_points(); delete qrule_face; delete fe; } } }
void MaxQpsThread::operator() (const ConstElemRange & range) { ParallelUniqueId puid; _tid = puid.id; Assembly & assembly = _fe_problem.assembly(_tid); for (ConstElemRange::const_iterator elem_it = range.begin() ; elem_it != range.end(); ++elem_it) { const Elem * elem = *elem_it; assembly.reinit(elem); unsigned int qps = 4; // assembly.qPoints().size(); if (qps > _max) _max = qps; } }
void ComputeJacobianBlockThread::operator() (const ConstElemRange & range, bool bypass_threading/*=false*/) { ParallelUniqueId puid; _tid = bypass_threading ? 0 : puid.id; unsigned int subdomain = std::numeric_limits<unsigned int>::max(); const DofMap & dof_map = _precond_system.get_dof_map(); std::vector<unsigned int> dof_indices; ConstElemRange::const_iterator range_end = range.end(); for (ConstElemRange::const_iterator el = range.begin() ; el != range_end; ++el) { const Elem* elem = *el; unsigned int cur_subdomain = elem->subdomain_id(); dof_map.dof_indices(elem, dof_indices); if (dof_indices.size()) { _fe_problem.prepare(elem, _ivar, _jvar, dof_indices, _tid); _fe_problem.reinitElem(elem, _tid); if (cur_subdomain != subdomain) { subdomain = cur_subdomain; _fe_problem.subdomainSetup(subdomain, _tid); _nl._kernels[_tid].updateActiveKernels(cur_subdomain); } _fe_problem.reinitMaterials(cur_subdomain, _tid); //Kernels std::vector<KernelBase *> kernels = _nl._kernels[_tid].active(); for (std::vector<KernelBase *>::const_iterator it = kernels.begin(); it != kernels.end(); it++) { KernelBase * kernel = *it; if (kernel->variable().index() == _ivar) { kernel->subProblem().prepareShapes(_jvar, _tid); kernel->computeOffDiagJacobian(_jvar); } } _fe_problem.swapBackMaterials(_tid); for (unsigned int side = 0; side < elem->n_sides(); side++) { std::vector<BoundaryID> boundary_ids = _mesh.boundaryIDs(elem, side); if (boundary_ids.size() > 0) { for (std::vector<BoundaryID>::iterator it = boundary_ids.begin(); it != boundary_ids.end(); ++it) { BoundaryID bnd_id = *it; std::vector<IntegratedBC *> bcs = _nl._bcs[_tid].activeIntegrated(bnd_id); if (bcs.size() > 0) { _fe_problem.prepareFace(elem, _tid); _fe_problem.reinitElemFace(elem, side, bnd_id, _tid); _fe_problem.reinitMaterialsFace(elem->subdomain_id(), _tid); _fe_problem.reinitMaterialsBoundary(bnd_id, _tid); for (std::vector<IntegratedBC *>::iterator it = bcs.begin(); it != bcs.end(); ++it) { IntegratedBC * bc = *it; if (bc->variable().index() == _ivar) { if (bc->shouldApply()) { bc->subProblem().prepareFaceShapes(_jvar, _tid); bc->computeJacobianBlock(_jvar); } } } _fe_problem.swapBackMaterialsFace(_tid); } } } if (elem->neighbor(side) != NULL) { // on internal edge // Pointer to the neighbor we are currently working on. const Elem * neighbor = elem->neighbor(side); // Get the global id of the element and the neighbor const unsigned int elem_id = elem->id(); const unsigned int neighbor_id = neighbor->id(); if ((neighbor->active() && (neighbor->level() == elem->level()) && (elem_id < neighbor_id)) || (neighbor->level() < elem->level())) { std::vector<DGKernel *> dgks = _nl._dg_kernels[_tid].active(); if (dgks.size() > 0) { _fe_problem.prepareFace(elem, _tid); _fe_problem.reinitNeighbor(elem, side, _tid); _fe_problem.reinitMaterialsFace(elem->subdomain_id(), _tid); _fe_problem.reinitMaterialsNeighbor(neighbor->subdomain_id(), _tid); for (std::vector<DGKernel *>::iterator it = dgks.begin(); it != dgks.end(); ++it) { DGKernel * dg = *it; if (dg->variable().index() == _ivar) { dg->subProblem().prepareFaceShapes(_jvar, _tid); dg->subProblem().prepareNeighborShapes(_jvar, _tid); dg->computeOffDiagJacobian(_jvar); } } _fe_problem.swapBackMaterialsFace(_tid); _fe_problem.swapBackMaterialsNeighbor(_tid); std::vector<unsigned int> neighbor_dof_indices; dof_map.dof_indices(neighbor, neighbor_dof_indices); { Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); _fe_problem.addJacobianNeighbor(_jacobian, _ivar, _jvar, dof_map, dof_indices, neighbor_dof_indices, _tid); } } } } } { Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); _fe_problem.addJacobianBlock(_jacobian, _ivar, _jvar, dof_map, dof_indices, _tid); } } } }