Vector<ResultType> reallyCalculateProjections( const Space<BasisFunctionType> &dualSpace, Fiber::LocalAssemblerForGridFunctions<ResultType> &assembler, const AssemblyOptions &options) { // TODO: parallelise using TBB (the parameter options will then start be used) // Get the grid's leaf view so that we can iterate over elements const GridView &view = dualSpace.gridView(); const size_t elementCount = view.entityCount(0); // Global DOF indices corresponding to local DOFs on elements std::vector<std::vector<GlobalDofIndex>> testGlobalDofs(elementCount); std::vector<std::vector<BasisFunctionType>> testLocalDofWeights(elementCount); // Gather global DOF lists const Mapper &mapper = view.elementMapper(); std::unique_ptr<EntityIterator<0>> it = view.entityIterator<0>(); while (!it->finished()) { const Entity<0> &element = it->entity(); const int elementIndex = mapper.entityIndex(element); dualSpace.getGlobalDofs(element, testGlobalDofs[elementIndex], testLocalDofWeights[elementIndex]); it->next(); } // Make a vector of all element indices std::vector<int> testIndices(elementCount); for (size_t i = 0; i < elementCount; ++i) testIndices[i] = i; // Create the weak form's column vector Vector<ResultType> result(dualSpace.globalDofCount()); result.setZero(); std::vector<Vector<ResultType>> localResult; // Evaluate local weak forms assembler.evaluateLocalWeakForms(testIndices, localResult); // Loop over test indices for (size_t testIndex = 0; testIndex < elementCount; ++testIndex) // Add the integrals to appropriate entries in the global weak form for (size_t testDof = 0; testDof < testGlobalDofs[testIndex].size(); ++testDof) { int testGlobalDof = testGlobalDofs[testIndex][testDof]; if (testGlobalDof >= 0) // if it's negative, it means that this // local dof is constrained (not used) result(testGlobalDof) += conj(testLocalDofWeights[testIndex][testDof]) * localResult[testIndex](testDof); } // Return the vector of projections <phi_i, f> return result; }
static void collectGridData( const Space<BasisFunctionType>& space, shared_ptr<Fiber::RawGridGeometry<CoordinateType> >& rawGeometry, shared_ptr<GeometryFactory>& geometryFactory) { typedef Fiber::RawGridGeometry<CoordinateType> RawGridGeometry; rawGeometry = boost::make_shared<RawGridGeometry>(space.gridDimension(), space.worldDimension()); const GridView& view = space.gridView(); view.getRawElementData( rawGeometry->vertices(), rawGeometry->elementCornerIndices(), rawGeometry->auxData(), rawGeometry->domainIndices()); geometryFactory = space.elementGeometryFactory(); }
int maximumShapesetOrder(const Space<BasisFunctionType>& space) { const GridView& view = space.gridView(); int maxOrder = 0; std::auto_ptr<EntityIterator<0> > it = view.entityIterator<0>(); while (!it->finished()) { const Entity<0>& e = it->entity(); maxOrder = std::max(maxOrder, space.shapeset(e).order()); it->next(); } return maxOrder; }