Skip to content

Commit

Permalink
Concerns the previous commit: Also initialize the exports for the mas…
Browse files Browse the repository at this point in the history
…s terms (if regulated by the flag).
  • Loading branch information
LogashenkoDL committed Nov 17, 2024
1 parent 4a032df commit 6a6e21d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ugbase/bridge/disc_bridges/domain_disc_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void DomainAlgebra(Registry& reg, string grp)
.add_method("add", static_cast<void (T::*)(SmartPtr<IElemDisc<TDomain> >)>(&T::add), "", "Element Discretization")
.add_method("remove", static_cast<void (T::*)(SmartPtr<IElemDisc<TDomain> >)>(&T::remove), "", "Element Discretization")
.add_method("add", static_cast<void (T::*)(SmartPtr<IDiscretizationItem<TDomain, TAlgebra> >)>(&T::add), "", "DiscItem")
.add_method("init_all_exports", static_cast<void (T::*)()>(&T::init_all_exports))
.add_method("init_all_exports", static_cast<void (T::*)(bool)>(&T::init_all_exports))
.add_method("assemble_linear", static_cast<void (T::*)(typename TAlgebra::matrix_type&, GridFunction<TDomain, TAlgebra>&)>(&T::assemble_linear))
.add_method("assemble_rhs", static_cast<void (T::*)(typename TAlgebra::vector_type&, GridFunction<TDomain, TAlgebra>&)>(&T::assemble_rhs))
.add_method("assemble_rhs", static_cast<void (T::*)(GridFunction<TDomain, TAlgebra>&)>(&T::assemble_rhs))
Expand Down
2 changes: 1 addition & 1 deletion ugbase/lib_disc/spatial_disc/dom_disc_embb.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class LSGFGlobAssembler
ConstSmartPtr<DoFDistribution> dd,
TIterator iterBegin,
TIterator iterEnd,
int si, bool bNonRegularGrid);
int si, bool bNonRegularGrid, bool bAsTimeDependent);

////////////////////////////////////////////////////////////////////////////////
// Error estimators: Not implemented for the ghost-fluid method
Expand Down
9 changes: 7 additions & 2 deletions ugbase/lib_disc/spatial_disc/dom_disc_embb_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,7 @@ FinishTimestepElem(const std::vector<IElemDisc<domain_type>*>& vElemDisc,
* \param[in] iterEnd element iterator
* \param[in] si subset index
* \param[in] bNonRegularGrid flag to indicate if non regular grid is used
* \param[in] bAsTimeDependent flag to simulate the instationary case for the initialization
*/
template <typename TDomain, typename TAlgebra, typename TExtrapolation>
template <typename TElem, typename TIterator>
Expand All @@ -2036,19 +2037,23 @@ InitAllExports(const std::vector<IElemDisc<domain_type>*>& vElemDisc,
ConstSmartPtr<DoFDistribution> dd,
TIterator iterBegin,
TIterator iterEnd,
int si, bool bNonRegularGrid)
int si, bool bNonRegularGrid, bool bAsTimeDependent)
{
// check if there are any elements at all, otherwise return immediately
if(iterBegin == iterEnd) return;

// reference object id
static const ReferenceObjectID id = geometry_traits<TElem>::REFERENCE_OBJECT_ID;

// dummy local time series (only to simulate the instationary case for the initialization)
LocalVectorTimeSeries locTimeSeries;

// prepare for given elem discs
try
{
DataEvaluator<domain_type> Eval(MASS | STIFF | RHS,
vElemDisc, dd->function_pattern(), bNonRegularGrid);
vElemDisc, dd->function_pattern(), bNonRegularGrid,
bAsTimeDependent? &locTimeSeries : NULL);
Eval.set_time_point(0);

// prepare loop
Expand Down
12 changes: 6 additions & 6 deletions ugbase/lib_disc/spatial_disc/domain_disc.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ class DomainDiscretizationBase
///////////////////////////
// Mass and Stiffness Matrix
///////////////////////////
virtual void init_all_exports(ConstSmartPtr<DoFDistribution> dd);
virtual void init_all_exports(const GridLevel& gl)
{init_all_exports(dd(gl));}
void init_all_exports()
{init_all_exports(GridLevel(GridLevel::TOP));}
virtual void init_all_exports(ConstSmartPtr<DoFDistribution> dd, bool bAsTimeDependent);
virtual void init_all_exports(const GridLevel& gl, bool bAsTimeDependent)
{init_all_exports(dd(gl), bAsTimeDependent);}
void init_all_exports(bool bAsTimeDependent)
{init_all_exports(GridLevel(GridLevel::TOP), bAsTimeDependent);}

/// assembles the mass matrix
virtual void assemble_mass_matrix(matrix_type& M, const vector_type& u,
Expand Down Expand Up @@ -629,7 +629,7 @@ class DomainDiscretizationBase
template <typename TElem>
void InitAllExports( const std::vector<IElemDisc<domain_type>*>& vElemDisc,
ConstSmartPtr<DoFDistribution> dd,
int si, bool bNonRegularGrid);
int si, bool bNonRegularGrid, bool bAsTimeDependent);
};

/// domain discretization implementing the interface
Expand Down
33 changes: 17 additions & 16 deletions ugbase/lib_disc/spatial_disc/domain_disc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ adjust_solution(vector_type& u, number time, ConstSmartPtr<DoFDistribution> dd)

template <typename TDomain, typename TAlgebra, typename TGlobAssembler>
void DomainDiscretizationBase<TDomain, TAlgebra, TGlobAssembler>::
init_all_exports(ConstSmartPtr<DoFDistribution> dd)
init_all_exports(ConstSmartPtr<DoFDistribution> dd, bool bAsTimeDependent)
{
PROFILE_FUNC_GROUP("discretization");
// update the elem discs
Expand Down Expand Up @@ -2152,37 +2152,37 @@ init_all_exports(ConstSmartPtr<DoFDistribution> dd)
{
case 0:
this->template InitAllExports<RegularVertex>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
break;
case 1:
this->template InitAllExports<RegularEdge>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
// When assembling over lower-dim manifolds that contain hanging nodes:
this->template InitAllExports<ConstrainingEdge>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
break;
case 2:
this->template InitAllExports<Triangle>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
this->template InitAllExports<Quadrilateral>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
// When assembling over lower-dim manifolds that contain hanging nodes:
this->template InitAllExports<ConstrainingTriangle>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
this->template InitAllExports<ConstrainingQuadrilateral>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
break;
case 3:
this->template InitAllExports<Tetrahedron>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
this->template InitAllExports<Pyramid>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
this->template InitAllExports<Prism>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
this->template InitAllExports<Hexahedron>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
this->template InitAllExports<Octahedron>
(vSubsetElemDisc, dd, si, bNonRegularGrid);
(vSubsetElemDisc, dd, si, bNonRegularGrid, bAsTimeDependent);
break;
default:
UG_THROW("DomainDiscretization::init_all_exports:"
Expand All @@ -2209,13 +2209,14 @@ init_all_exports(ConstSmartPtr<DoFDistribution> dd)
* \param[in] dd DoF Distribution
* \param[in] si subset index
* \param[in] bNonRegularGrid flag to indicate if non regular grid is used
* \param[in] bAsTimeDependent flag to simulate the instationary case for the initialization
*/
template <typename TDomain, typename TAlgebra, typename TGlobAssembler>
template <typename TElem>
void DomainDiscretizationBase<TDomain, TAlgebra, TGlobAssembler>::
InitAllExports( const std::vector<IElemDisc<domain_type>*>& vElemDisc,
ConstSmartPtr<DoFDistribution> dd,
int si, bool bNonRegularGrid)
int si, bool bNonRegularGrid, bool bAsTimeDependent)
{
// check if only some elements are selected
if(m_spAssTuner->selected_elements_used())
Expand All @@ -2226,15 +2227,15 @@ InitAllExports( const std::vector<IElemDisc<domain_type>*>& vElemDisc,
// assembling is carried out only over those elements
// which are selected and in subset si
gass_type::template InitAllExports<TElem>
(vElemDisc, dd, vElem.begin(), vElem.end(), si, bNonRegularGrid);
(vElemDisc, dd, vElem.begin(), vElem.end(), si, bNonRegularGrid, bAsTimeDependent);
}
else
{
// general case: assembling over all elements in subset si
gass_type::template InitAllExports<TElem>
(vElemDisc, dd,
dd->template begin<TElem>(si), dd->template end<TElem>(si), si,
bNonRegularGrid);
bNonRegularGrid, bAsTimeDependent);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1850,26 +1850,31 @@ class StdGlobAssembler
* \param[in] iterEnd element iterator
* \param[in] si subset index
* \param[in] bNonRegularGrid flag to indicate if non regular grid is used
* \param[in] bAsTimeDependent flag to simulate the instationary case for the initialization
*/
template <typename TElem, typename TIterator>
static void
InitAllExports(const std::vector<IElemDisc<domain_type>*>& vElemDisc,
ConstSmartPtr<DoFDistribution> dd,
TIterator iterBegin,
TIterator iterEnd,
int si, bool bNonRegularGrid)
int si, bool bNonRegularGrid, bool bAsTimeDependent)
{
// check if there are any elements at all, otherwise return immediately
if(iterBegin == iterEnd) return;

// reference object id
static const ReferenceObjectID id = geometry_traits<TElem>::REFERENCE_OBJECT_ID;

// dummy local time series (only to simulate the instationary case for the initialization)
LocalVectorTimeSeries locTimeSeries;

// prepare for given elem discs
try
{
DataEvaluator<domain_type> Eval(MASS | STIFF | RHS,
vElemDisc, dd->function_pattern(), bNonRegularGrid);
vElemDisc, dd->function_pattern(), bNonRegularGrid,
bAsTimeDependent? &locTimeSeries : NULL);
Eval.set_time_point(0);

// prepare loop
Expand Down

0 comments on commit 6a6e21d

Please sign in to comment.