LCOV - code coverage report
Current view: top level - ugbase/lib_disc/spatial_disc/user_data - data_evaluator.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 8 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 12 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2011-2017:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Andreas Vogel
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR__
      34              : #define __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR__
      35              : 
      36              : #include "lib_disc/spatial_disc/elem_disc/elem_disc_interface.h"
      37              : #include "lib_disc/spatial_disc/user_data/user_data.h"
      38              : #include "lib_disc/spatial_disc/user_data/data_import.h"
      39              : 
      40              : namespace ug{
      41              : 
      42              : enum ProcessType {PT_ALL=0, PT_STATIONARY, PT_INSTATIONARY, MAX_PROCESS};
      43              : 
      44              : /// helper class to evaluate data evaluation for local contributions during assembling
      45              : /**
      46              :  * This class is a helper class to facilitate the correct evaluation of data
      47              :  * during the assembling process. For a given set of IElemDisc this class
      48              :  * prepares the assembling, checks for DataImport/DataExports and schedules the
      49              :  * evaluation of the data in the correct order. In addition the coupling
      50              :  * contributions due to Import/Exports are computed by this class and can be
      51              :  * added to the local jacobian/defect.
      52              :  */
      53              : template <typename TDomain, typename TElemDisc> // TElemDisc = IElemDisc<TDomain>
      54              : class DataEvaluatorBase
      55              : {
      56              :         public:
      57              :         ///     world dimension
      58              :                 static const int dim = TDomain::dim;
      59              :                 
      60              :         public:
      61              :         ///     sets the elem discs to evaluate
      62              :                 DataEvaluatorBase(int discPart,
      63              :                               const std::vector<TElemDisc*>& vElemDisc,
      64              :                               ConstSmartPtr<FunctionPattern> fctPat,
      65              :                               const bool bNonRegularGrid,
      66              :                               LocalVectorTimeSeries* locTimeSeries = NULL,
      67              :                               const std::vector<number>* vScaleMass = NULL,
      68              :                               const std::vector<number>* vScaleStiff = NULL);
      69              : 
      70              :         ///     sets the time point for data evaluation
      71              :                 void set_time_point(const size_t timePoint);
      72              : 
      73              :         ///     returns if local time series is really needed for assembling
      74            0 :                 bool time_series_needed() const {return m_bNeedLocTimeSeries;}
      75              : 
      76              :         ///     returns if one of the element discs needs hanging dofs
      77            0 :                 bool use_hanging() const {return m_bUseHanging;}
      78              : 
      79              :                 
      80              : 
      81              :         ///     prepares the element loop for all IElemDiscs for the computation of the error estimator
      82              :                 void prepare_err_est_elem_loop(const ReferenceObjectID id, int si);
      83              : 
      84              :         ///     prepares the element for all IElemDiscs
      85              :                 void prepare_err_est_elem(LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[],
      86              :                                                                   const LocalIndices& ind, bool bDeriv = false);
      87              : 
      88              :         ///     compute contributions of the local error indicators in one element for all IElemDiscs
      89              :                 void compute_err_est_A_elem(LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], const LocalIndices& ind,
      90              :                                                                   const number scaleMass = (number) 1.0, const number scaleStiff = (number) 1.0);
      91              : 
      92              :         ///     compute contributions of the local error indicators in one element for all IElemDiscs
      93              :                 void compute_err_est_M_elem(LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], const LocalIndices& ind,
      94              :                                                                   const number scaleMass = (number) 1.0, const number scaleStiff = (number) 1.0);
      95              : 
      96              :         ///     compute contributions of the local error indicators in one element for all IElemDiscs
      97              :                 void compute_err_est_rhs_elem(GridObject* elem, const MathVector<dim> vCornerCoords[], const LocalIndices& ind,
      98              :                                                                   const number scaleMass = (number) 1.0, const number scaleStiff = (number) 1.0);
      99              : 
     100              :         ///     finishes the error estimator element loop for all IElemDiscs
     101              :                 void finish_err_est_elem_loop();
     102              : 
     103              :         protected:
     104              :         ///     clears imports and user data and mappings betweem commonFctGrp and local
     105              :                 void clear_extracted_data_and_mappings();
     106              : 
     107              :         ///     tries to add the last entry of vTryingToAdd to the eval data
     108              :                 void add_data_to_eval_data(std::vector<SmartPtr<ICplUserData<dim> > >& vEvalData,
     109              :                                                                    std::vector<SmartPtr<ICplUserData<dim> > >& vTryingToAdd);
     110              : 
     111              :         ///     extracts imports and userdata from IElemDiscs
     112              :                 void extract_imports_and_userdata(int subsetIndex, int discPart);
     113              : 
     114              :         ///     clears all requested positions in user data
     115              :                 void clear_positions_in_user_data();
     116              : 
     117              :         protected:
     118              :         ///     disc part needed (MASS and/or STIFF and/or RHS)
     119              :                 int m_discPart;
     120              : 
     121              :         ///     elem disc data
     122              :                 std::vector<TElemDisc*> m_vElemDisc[MAX_PROCESS];
     123              : 
     124              :         ///     underlying function pattern
     125              :                 ConstSmartPtr<FunctionPattern> m_spFctPattern;
     126              : 
     127              :         ///     flag if hanging nodes are used
     128              :                 bool m_bUseHanging;
     129              : 
     130              :         ///     flag indicating if any elem disc needs local time series
     131              :                 bool m_bNeedLocTimeSeries;
     132              : 
     133              :         ///     local time series (non-const since mapping may change)
     134              :                 LocalVectorTimeSeries* m_pLocTimeSeries;
     135              : 
     136              :         ///     imports that must be evaluated
     137              :                 std::vector<IDataImport<dim>*> m_vImport[MAX_PROCESS][MAX_PART];
     138              : 
     139              :         ///     user data that must be evaluated
     140              :         /// \{
     141              :                 std::vector<SmartPtr<ICplUserData<dim> > > m_vConstData;       //< constant data
     142              :                 std::vector<SmartPtr<ICplUserData<dim> > > m_vPosData;       //< position dependent data
     143              :                 std::vector<SmartPtr<ICplUserData<dim> > > m_vDependentData; //< dependent data
     144              :         /// \}
     145              : };
     146              : 
     147              : 
     148              : /// Evaluation for IElemError
     149              : template <typename TDomain>
     150            0 : class ErrorEvaluator : public DataEvaluatorBase<TDomain, IElemError<TDomain> >
     151              : {
     152              : public:
     153              :         ///     sets the elem discs to evaluate
     154            0 :         ErrorEvaluator(int discPart,
     155              :                               const std::vector<IElemError<TDomain> *>& vElemDisc,
     156              :                               ConstSmartPtr<FunctionPattern> fctPat,
     157              :                               const bool bNonRegularGrid,
     158              :                               LocalVectorTimeSeries* locTimeSeries = NULL,
     159              :                               const std::vector<number>* vScaleMass = NULL,
     160              :                               const std::vector<number>* vScaleStiff = NULL)
     161            0 :         : DataEvaluatorBase<TDomain, IElemError<TDomain> > (discPart, vElemDisc, fctPat, bNonRegularGrid, locTimeSeries, vScaleMass, vScaleStiff) {}
     162              : };
     163              : 
     164              : 
     165              : 
     166              : /// Evaluation for IElemDisc
     167              : template <typename TDomain>
     168            0 : class DataEvaluator : public DataEvaluatorBase<TDomain, IElemDisc<TDomain> >
     169              : {
     170              : 
     171              : public:
     172              :         typedef DataEvaluatorBase<TDomain, IElemDisc<TDomain> > base_type;
     173              :         using base_type::dim;
     174              : 
     175              :         ///     sets the elem discs to evaluate
     176            0 :         DataEvaluator(int discPart,
     177              :                               const std::vector<IElemDisc<TDomain> *>& vElemDisc,
     178              :                               ConstSmartPtr<FunctionPattern> fctPat,
     179              :                               const bool bNonRegularGrid,
     180              :                               LocalVectorTimeSeries* locTimeSeries = NULL,
     181              :                               const std::vector<number>* vScaleMass = NULL,
     182              :                               const std::vector<number>* vScaleStiff = NULL)
     183            0 :         : DataEvaluatorBase<TDomain, IElemDisc<TDomain> > (discPart, vElemDisc, fctPat, bNonRegularGrid, locTimeSeries, vScaleMass, vScaleStiff) {}
     184              : 
     185              : 
     186              :         ////////////////////////////////////////////
     187              :         // Regular assembling
     188              :         ///////////////////////////////////////////
     189              : 
     190              :                 ///     prepares all time-dependent IElemDiscs
     191              :                         void prepare_timestep(number future_time, const number time, VectorProxyBase* u, size_t algebra_id);
     192              : 
     193              :                 ///     prepares the elements of all time-dependent IElemDiscs
     194              :                         void prepare_timestep_elem(const number time, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
     195              : 
     196              :                 ///     prepares the element loop for all IElemDiscs
     197              :                         void prepare_elem_loop(const ReferenceObjectID id, int si);
     198              : 
     199              :                 ///     prepares the element for all IElemDiscs
     200              :                         void prepare_elem(LocalVector& u, GridObject* elem, const ReferenceObjectID roid, const MathVector<dim> vCornerCoords[],
     201              :                                           const LocalIndices& ind, bool bDeriv = false);
     202              : 
     203              :                 ///     finishes the element loop for all IElemDiscs
     204              :                         void finish_elem_loop();
     205              : 
     206              :                 /// finishes all time-dependent IElemDiscs
     207              :                         void finish_timestep(const number time, VectorProxyBase* u, size_t algebra_id);
     208              : 
     209              :                 ///     finishes the elements of all time-dependent IElemDiscs
     210              :                         void finish_timestep_elem(const number time, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
     211              : 
     212              :                 ///     compute local stiffness matrix for all IElemDiscs
     213              :                         void add_jac_A_elem(LocalMatrix& A, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
     214              : 
     215              :                 ///     compute local mass matrix for all IElemDiscs
     216              :                         void add_jac_M_elem(LocalMatrix& M, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
     217              : 
     218              :                 ///     compute local stiffness defect for all IElemDiscs
     219              :                         void add_def_A_elem(LocalVector& d, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
     220              : 
     221              :                 ///     compute local stiffness defect for all IElemDiscs explicit
     222              :                         void add_def_A_expl_elem(LocalVector& d, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
     223              : 
     224              :                 ///     compute local mass defect for all IElemDiscs
     225              :                         void add_def_M_elem(LocalVector& d, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
     226              : 
     227              :                 ///     compute local rhs for all IElemDiscs
     228              :                         void add_rhs_elem(LocalVector& rhs, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
     229              : 
     230              :                         using base_type::time_series_needed;
     231              : protected:
     232              : 
     233              :         using base_type::m_vElemDisc;
     234              :         using base_type::m_vImport;
     235              :         using base_type::m_vDependentData;
     236              :         using base_type::m_vConstData;
     237              :         using base_type::m_vPosData;
     238              :         using base_type::m_discPart;
     239              :         using base_type::m_pLocTimeSeries;
     240              : 
     241              :         using base_type::clear_positions_in_user_data;
     242              :         using base_type::extract_imports_and_userdata;
     243              : 
     244              : };
     245              : 
     246              : 
     247              : 
     248              : } // end namespace ug
     249              : 
     250              : #include "data_evaluator_impl.h"
     251              : 
     252              : #endif /* __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR__ */
        

Generated by: LCOV version 2.0-1