void AdaptionSurfaceGridFunction<TDomain>::
do_restrict(const MGSelector& sel, const GridMessage_Adaption& msg)
{
	const GridBaseObjectId gbo = (GridBaseObjectId)TBaseElem::BASE_OBJECT_ID;

//	extract and init prolongations working on the base element type
	std::vector<SmartPtr<IElemRestriction<TDomain> > > vpRestrict;
	for(size_t fct = 0; fct < m_vpRestrict.size(); ++fct){

		if(!m_vpRestrict[fct]->perform_restriction_on(gbo)) continue;

		m_vpRestrict[fct]->init(m_spDomain,
		                        make_sp(new ValueAccessor(*this, fct)),
		                        make_sp(new ValueAccessor(*this, fct)));

		vpRestrict.push_back(m_vpRestrict[fct]);
	}

//	check that something to do
	if(vpRestrict.empty()) return;

//	check that correct attachments used
	if(m_spDDInfo->max_dofs(gbo) == 0) return;

//	iterators
	typedef typename Selector::traits<TBaseElem>::const_level_iterator const_iterator;

	for(int lvl = sel.num_levels() - 1; lvl >= 0; --lvl)
	{
		const_iterator iter = sel.begin<TBaseElem>(lvl);
		const_iterator iterEnd = sel.end<TBaseElem>(lvl);

	//	loop base element type
		for( ; iter != iterEnd; ++iter)
		{
		//	get parent element, that has been refined
			TBaseElem* parent = *iter;

		//	add storage for parent
			obj_created(parent);

		//	call implementations
			for(size_t f = 0; f < vpRestrict.size(); ++f){
				vpRestrict[f]->do_restrict(parent);
			}
		}
	}
}
Esempio n. 2
0
void OrderDownwind(ApproximationSpace<TDomain>& approxSpace, const char* strVelocity, number threshold)
{
	static const int dim = TDomain::dim;

	SmartPtr<UserData<MathVector<dim>, dim> > spVelocity
	 = make_sp(new LuaUserData<MathVector<dim>, dim>(strVelocity));

	OrderDownwind<TDomain>(approxSpace, spVelocity, threshold);
}
SmartPtr<IElemProlongation<TDomain> >
GetStandardElementProlongation(const LFEID& lfeid)
{
	switch(lfeid.type()){
		case LFEID::LAGRANGE:
			if(lfeid.order() == 1)
				return make_sp(new P1LagrangeElemTransfer<TDomain>(lfeid));
			else
				return make_sp(new StdLagrangeElemTransfer<TDomain>(lfeid));
		case LFEID::PIECEWISE_CONSTANT:
			return make_sp(new PiecewiseConstantElemTransfer<TDomain>(lfeid));

		case LFEID::CROUZEIX_RAVIART:
			return make_sp(new CrouzeixRaviartElemTransfer<TDomain>(lfeid));

		default: UG_THROW("No Standard Element Prolongation found for "<<lfeid);
	}
}
Esempio n. 4
0
void SchurPrecond<TAlgebra>::
create_aux_vectors(const vector_type& d)
{
	const SlicingData sd    = m_spSchurComplementOp->slicing();
	const size_t n_inner    = m_spSchurComplementOp->sub_size(SD_INNER);
	const size_t n_skeleton = m_spSchurComplementOp->sub_size(SD_SKELETON);
	(void) n_skeleton; // warning fix

	// create vectors
	if (m_aux_rhs[SD_SKELETON].invalid())
	{
		UG_DLOG(SchurDebug, 1, "% Creating skeleton defect vector of size " << n_skeleton << std::endl);
		//m_aux_rhs[SD_SKELETON] = new vector_type(n_skeleton);
		m_aux_rhs[SD_SKELETON] = sd.slice_clone_without_values(d, SD_SKELETON);
		m_aux_rhs[SD_SKELETON]->set_storage_type(PST_ADDITIVE);
		//std::cerr<< "Skeleton f:\n" <<*m_aux_rhs[SD_SKELETON]->layouts();
	}

	if (m_aux_sol[SD_SKELETON].invalid())
	{
		UG_DLOG(SchurDebug, 1, "% Creating skeleton corr vector of size " << n_skeleton << std::endl);
		//m_aux_sol[SD_SKELETON] = new vector_type(n_skeleton);
		m_aux_sol[SD_SKELETON] = sd.slice_clone_without_values(d, SD_SKELETON);
		m_aux_sol[SD_SKELETON]->set_storage_type(PST_CONSISTENT);
		//std::cerr<< "Skeleton u:\n" << *m_aux_sol[SD_SKELETON]->layouts();
	}

	if (m_aux_rhs[SD_INNER].invalid())
	{
		UG_DLOG(SchurDebug, 1, "% Creating inner defect vector of size " << n_inner << std::endl);
		m_aux_rhs[SD_INNER] = make_sp(new vector_type(n_inner));
		m_aux_rhs[SD_INNER]->set_storage_type(PST_ADDITIVE);
	}

	if (m_aux_sol[SD_INNER].invalid())
	{
		UG_DLOG(SchurDebug, 1, "% Creating inner corr vector of size " << n_inner << std::endl);
		m_aux_sol[SD_INNER] = make_sp(new vector_type(n_inner));
		m_aux_sol[SD_INNER]->set_storage_type(PST_CONSISTENT);
	}
}
void AdaptionSurfaceGridFunction<TDomain>::
prolongate(const GridMessage_Adaption& msg, const size_t lvl)
{
	const GridBaseObjectId gbo = (GridBaseObjectId)TBaseElem::BASE_OBJECT_ID;

//	extract and init prolongations working on the base element type
	std::vector<SmartPtr<IElemProlongation<TDomain> > > vpProlong;
	for(size_t fct = 0; fct < m_vpProlong.size(); ++fct){

		if(!m_vpProlong[fct]->perform_prolongation_on(gbo)) continue;

		m_vpProlong[fct]->init(m_spDomain,
		                       make_sp(new ValueAccessor(*this, fct)),
		                       make_sp(new ValueAccessor(*this, fct)));

		vpProlong.push_back(m_vpProlong[fct]);
	}

//	check that something to do
	if(vpProlong.empty()) return;

//	iterators
	const GridObjectCollection& goc = msg.affected_elements();
	typedef typename GridObjectCollection::traits<TBaseElem>::const_iterator const_iterator;


	const_iterator iter = goc.begin<TBaseElem>(lvl);
	const_iterator iterEnd = goc.end<TBaseElem>(lvl);

//	loop base element type
	for( ; iter != iterEnd; ++iter)
	{
	//	get parent element, that has been refined
		TBaseElem* parent = *iter;

	//	call implementations
		for(size_t f = 0; f < vpProlong.size(); ++f){
			vpProlong[f]->prolongate(parent);
		}
	}
}
Esempio n. 6
0
bool SchurPrecond<TAlgebra>::
create_and_init_local_schur_complement(SmartPtr<MatrixOperator<matrix_type, vector_type> > A,
		std::vector<slice_desc_type> &skeletonMark)
{
	try{
	SCHUR_PROFILE_BEGIN(SchurPrecondInit_CreateInitLocalSchurComplement);

	m_spSchurComplementOp = make_sp(new SchurComplementOperator<TAlgebra>(A, skeletonMark));
	if (m_spSchurComplementOp.invalid())
	{
		UG_ASSERT(m_spSchurComplementOp.invalid(), "Failed creating operator!")
	}

//	set dirichlet solver for local Schur complement
	m_spSchurComplementOp->set_dirichlet_solver(m_spDirichletSolver);

	if(debug_writer().valid())
		m_spSchurComplementOp->set_debug(debug_writer());

//	init
	UG_DLOG(SchurDebug, 1, "\n%   - Init local Schur complement ... ");

	m_spSchurComplementOp->init();
	UG_DLOG(SchurDebug, 1, "done.\n");


//	1.4 check all procs
	/*bool bSuccess = true;
	if(!pcl::AllProcsTrue(bSuccess))
	{
		UG_LOG("ERROR in SchurPrecond::init: Some processes could not init"
				" local Schur complement.\n");
		return false;
	}*/
	return true;

	}UG_CATCH_THROW("SchurPrecond::" << __FUNCTION__ << " failed")
	return false;
}
void ConvectionDiffusionBase<TDomain>::set_diffusion(LuaFunctionHandle fct)
{
	set_diffusion(make_sp(new LuaUserData<MathMatrix<dim,dim>, dim>(fct)));
}
void ConvectionDiffusionBase<TDomain>::set_diffusion(number val)
{
	if(val == 0.0) set_diffusion(SmartPtr<CplUserData<MathMatrix<dim, dim>, dim> >());
	else set_diffusion(make_sp(new ConstUserMatrix<dim>(val)));
}
void ConvectionDiffusionBase<TDomain>::
set_mass(LuaFunctionHandle fct)
{
	set_mass(make_sp(new LuaUserData<number,dim>(fct)));
}
void ConvectionDiffusionBase<TDomain>::
set_mass(number val)
{
	if(val == 0.0) set_mass(SmartPtr<CplUserData<number, dim> >());
	else set_mass(make_sp(new ConstUserNumber<dim>(val)));
}
void ConvectionDiffusionBase<TDomain>::
set_vector_source(LuaFunctionHandle fct)
{
	set_vector_source(make_sp(new LuaUserData<MathVector<dim>,dim>(fct)));
}
Esempio n. 12
0
////////////////////////////////////////////////////////////////////////////////
//	IMPLEMENTATION OF PartitionMap
PartitionMap::PartitionMap()
{
	m_shPartitions = make_sp(new SubsetHandler());
}