33 #ifndef __H__UG__LIB_DISC__FUNCTION_SPACES__INTEGRATE_FLUX__
34 #define __H__UG__LIB_DISC__FUNCTION_SPACES__INTEGRATE_FLUX__
49 template <
typename TGr
idFunction,
int dim>
51 const TGridFunction& rDefect,
56 typedef typename TGridFunction::template dim_traits<dim>::const_iterator const_iterator;
57 typedef typename TGridFunction::template dim_traits<dim>::grid_base_object element_type;
58 const_iterator iter = rDefect.template begin<element_type>(si);
59 const_iterator iterEnd = rDefect.template end<element_type>(si);
62 if(rDefect.max_dofs(
dim) == 0)
return;
65 if(vValue.size() != fctGrp.
size())
66 UG_THROW(
"IntegrateDiscFlux: number of values and number of function mismatch.");
69 std::vector<std::vector<DoFIndex> > vInd(fctGrp.
size());
72 for( ; iter != iterEnd; ++iter)
75 element_type* elem = *iter;
78 for(
size_t f = 0; f < fctGrp.
size(); ++f)
79 rDefect.inner_dof_indices(elem, fctGrp[f], vInd[f]);
82 for(
size_t f = 0; f < fctGrp.
size(); ++f)
83 for(
size_t i = 0; i < vInd[f].size(); ++i)
84 vValue[f] +=
DoFRef( rDefect, vInd[f][i]);
89 template <
typename TGr
idFunction>
96 SubsetGroup ssGrp(spGridFct->domain()->subset_handler());
101 UG_THROW(
"IntegrateDiscFlux: Subsets '"<<subsets<<
"' do not have same dimension."
102 "Can not integrate on subsets of different dimensions.");
115 if(fctGrp.
size() == 0)
return 0;
118 TGridFunction Defect(*spGridFct);
123 const int ElemTypesEnabled = spAssTuner->enabled_elem_discs();
124 const int ConstraintTypesEnabled = spAssTuner->enabled_constraints();
127 spAssTuner->enable_elem_discs(ElemTypesEnabled & (~
EDT_BND));
128 spAssTuner->enable_constraints(ConstraintTypesEnabled & (~
CT_DIRICHLET));
131 spAssemble->assemble_defect(Defect, *spGridFct);
134 spAssTuner->enable_elem_discs(ElemTypesEnabled);
135 spAssTuner->enable_constraints(ConstraintTypesEnabled);
138 std::vector<number> vValue(fctGrp.
size(), 0);
141 for(
size_t i = 0; i < ssGrp.
size(); ++i)
144 const int si = ssGrp[i];
147 for(
size_t f = 0; f < fctGrp.
size(); ++f)
149 if(!spGridFct->is_def_in_subset(fctGrp[f], si))
150 UG_THROW(
"IntegrateDiscFlux: Function "<<fctGrp[f]<<
" not defined "
151 "on subset "<<si<<
".");
156 UG_THROW(
"IntegrateDiscFlux: Dimension of subset is "<<ssGrp.
dim(i)<<
", but "
161 for(
int d = 0; d < ssGrp.
dim(i)+1; ++d)
163 if(d==0) IntegrateDiscFlux<TGridFunction, 0>(vValue, Defect, fctGrp, si);
164 else if(d==1) IntegrateDiscFlux<TGridFunction, 1>(vValue, Defect, fctGrp, si);
165 else if(d==2) IntegrateDiscFlux<TGridFunction, 2>(vValue, Defect, fctGrp, si);
166 else if(d==3) IntegrateDiscFlux<TGridFunction, 3>(vValue, Defect, fctGrp, si);
167 else UG_THROW(
"IntegrateDiscFlux: Dimension "<<d<<
" not supported. "
171 UG_CATCH_THROW(
"IntegrateSubsets: Integration failed on subset "<<si);
180 for(
size_t f = 0; f < vValue.size(); ++f)
189 if(vValue.size() == 1)
return vValue[0];
193 for(
size_t f = 0; f < vValue.size(); ++f){
194 UG_LOG(
"Integral for '"<<fctGrp.
name(f)<<
"': "<<vValue[f]<<
"\n");
Definition: smart_pointer.h:108
Definition: pcl_process_communicator.h:70
void allreduce(const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op) const
performs MPI_Allreduce on the processes of the communicator.
Definition: pcl_process_communicator.cpp:318
Definition: function_group.h:52
const char * name(size_t i) const
returns the name of a function
Definition: function_group.cpp:205
size_t size() const
number of functions in this group
Definition: function_group.h:116
Interface providing Jacobian and Defect of a discretization.
Definition: assemble_interface.h:110
Group of subsets.
Definition: subset_group.h:51
size_t size() const
number of subsets in this group
Definition: subset_group.h:122
void add_all()
select all subsets of underlying subset handler
Definition: subset_group.cpp:133
int dim(size_t i) const
dimension of subset
Definition: subset_group.cpp:237
void add(int si)
adds a subset by number to this group
Definition: subset_group.cpp:64
#define PCL_RO_SUM
Definition: pcl_methods.h:63
#define PCL_DT_DOUBLE
Definition: pcl_datatype.h:57
int NumProcs()
returns the number of processes
Definition: pcl_base.cpp:91
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
double number
Definition: types.h:124
int local(bglp_vertex_descriptor p)
Definition: parallel_matrix.h:57
@ CT_DIRICHLET
Definition: ass_tuner.h:59
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition: multi_index.h:276
@ EDT_BND
Definition: elem_disc_interface.h:63
void TokenizeString(const string &str, vector< string > &vToken, const char delimiter)
Definition: string_util.cpp:56
bool SameDimensionsInAllSubsets(const SubsetGroup &subsetGroup)
Definition: subset_group.cpp:299
void RemoveLowerDimSubsets(SubsetGroup &subsetGroup)
Definition: subset_group.cpp:315
void IntegrateDiscFlux(std::vector< number > &vValue, const TGridFunction &rDefect, const FunctionGroup &fctGrp, int si)
Definition: integrate_flux.h:50