/usr/include/dune/pdelab/gridoperator/default/nonlinearjacobianapplyengine.hh is in libdune-pdelab-dev 2.5.0~20170124g7cf9f47a-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | #ifndef DUNE_PDELAB_GRIDOPERATOR_DEFAULT_NONLINEARJACOBIANAPPLYENGINE_HH
#define DUNE_PDELAB_GRIDOPERATOR_DEFAULT_NONLINEARJACOBIANAPPLYENGINE_HH
#include <dune/pdelab/gridfunctionspace/localvector.hh>
#include <dune/pdelab/gridoperator/common/assemblerutilities.hh>
#include <dune/pdelab/gridoperator/common/localassemblerenginebase.hh>
#include <dune/pdelab/constraints/common/constraints.hh>
#include <dune/pdelab/localoperator/callswitch.hh>
namespace Dune{
namespace PDELab{
/**
\brief The local assembler engine for DUNE grids which
assembles the local application of the Jacobian
\tparam LA The local assembler
*/
template<typename LA>
class DefaultLocalNonlinearJacobianApplyAssemblerEngine
: public LocalAssemblerEngineBase
{
public:
template<typename TrialConstraintsContainer, typename TestConstraintsContainer>
bool needsConstraintsCaching(const TrialConstraintsContainer& cu, const TestConstraintsContainer& cv) const
{
return false;
}
//! The type of the wrapping local assembler
typedef LA LocalAssembler;
//! The type of the local operator
typedef typename LA::LocalOperator LOP;
//! The type of the residual vector
typedef typename LA::Traits::Residual Residual;
typedef typename Residual::ElementType ResidualElement;
//! The type of the solution vector
typedef typename LA::Traits::Solution Solution;
typedef typename Solution::ElementType SolutionElement;
//! The local function spaces
typedef typename LA::LFSU LFSU;
typedef typename LA::LFSUCache LFSUCache;
typedef typename LFSU::Traits::GridFunctionSpace GFSU;
typedef typename LA::LFSV LFSV;
typedef typename LA::LFSVCache LFSVCache;
typedef typename LFSV::Traits::GridFunctionSpace GFSV;
typedef typename Solution::template ConstLocalView<LFSUCache> SolutionView;
typedef typename Residual::template LocalView<LFSVCache> ResidualView;
/**
\brief Constructor
\param [in] local_assembler_ The local assembler object which
creates this engine
*/
DefaultLocalNonlinearJacobianApplyAssemblerEngine(const LocalAssembler & local_assembler_)
: local_assembler(local_assembler_), lop(local_assembler_.lop),
rl_view(rl,1.0),
rn_view(rn,1.0)
{}
//! Query methods for the global grid assembler
//! @{
bool requireSkeleton() const
{ return local_assembler.doAlphaSkeleton(); }
bool requireSkeletonTwoSided() const
{ return local_assembler.doSkeletonTwoSided(); }
bool requireUVVolume() const
{ return local_assembler.doAlphaVolume(); }
bool requireUVSkeleton() const
{ return local_assembler.doAlphaSkeleton(); }
bool requireUVBoundary() const
{ return local_assembler.doAlphaBoundary(); }
bool requireUVVolumePostSkeleton() const
{ return local_assembler.doAlphaVolumePostSkeleton(); }
//! @}
//! Public access to the wrapping local assembler
const LocalAssembler & localAssembler() const { return local_assembler; }
//! Trial space constraints
const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints& trialConstraints() const
{
return localAssembler().trialConstraints();
}
//! Test space constraints
const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints& testConstraints() const
{
return localAssembler().testConstraints();
}
//! Set current residual vector. Should be called prior to
//! assembling.
void setResidual(Residual & residual_){
global_rl_view.attach(residual_);
global_rn_view.attach(residual_);
}
//! Set current solution vector. Should be called prior to
//! assembling.
void setSolution(const Solution & solution_){
global_sl_view.attach(solution_);
global_sn_view.attach(solution_);
}
//! Set current solution vector. Should be called prior to
//! assembling.
void setUpdate(const Solution & update_){
global_zl_view.attach(update_);
global_zn_view.attach(update_);
}
//! Called immediately after binding of local function space in
//! global assembler.
//! @{
template<typename EG, typename LFSUC, typename LFSVC>
void onBindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache){
global_sl_view.bind(lfsu_cache);
xl.resize(lfsu_cache.size());
global_zl_view.bind(lfsu_cache);
zl.resize(lfsu_cache.size());
}
template<typename EG, typename LFSVC>
void onBindLFSV(const EG & eg, const LFSVC & lfsv_cache){
global_rl_view.bind(lfsv_cache);
rl.assign(lfsv_cache.size(),0.0);
}
template<typename IG, typename LFSUC, typename LFSVC>
void onBindLFSUVInside(const IG & ig, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache){
global_sl_view.bind(lfsu_cache);
xl.resize(lfsu_cache.size());
global_zl_view.bind(lfsu_cache);
zl.resize(lfsu_cache.size());
}
template<typename IG, typename LFSUC, typename LFSVC>
void onBindLFSUVOutside(const IG & ig,
const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
{
global_sn_view.bind(lfsu_n_cache);
xn.resize(lfsu_n_cache.size());
global_zn_view.bind(lfsu_n_cache);
zn.resize(lfsu_n_cache.size());
}
template<typename IG, typename LFSVC>
void onBindLFSVInside(const IG & ig, const LFSVC & lfsv_cache){
global_rl_view.bind(lfsv_cache);
rl.assign(lfsv_cache.size(),0.0);
}
template<typename IG, typename LFSVC>
void onBindLFSVOutside(const IG & ig,
const LFSVC & lfsv_s_cache,
const LFSVC & lfsv_n_cache)
{
global_rn_view.bind(lfsv_n_cache);
rn.assign(lfsv_n_cache.size(),0.0);
}
//! @}
//! Called when the local function space is about to be rebound or
//! discarded
//! @{
template<typename EG, typename LFSVC>
void onUnbindLFSV(const EG & eg, const LFSVC & lfsv_cache){
global_rl_view.add(rl);
global_rl_view.commit();
}
template<typename IG, typename LFSVC>
void onUnbindLFSVInside(const IG & ig, const LFSVC & lfsv_cache){
global_rl_view.add(rl);
global_rl_view.commit();
}
template<typename IG, typename LFSVC>
void onUnbindLFSVOutside(const IG & ig,
const LFSVC & lfsv_s_cache,
const LFSVC & lfsv_n_cache)
{
global_rn_view.add(rn);
global_rn_view.commit();
}
//! @}
//! Methods for loading of the local function's coefficients
//! @{
template<typename LFSUC>
void loadCoefficientsLFSUInside(const LFSUC & lfsu_s_cache){
global_sl_view.read(xl);
global_zl_view.read(zl);
}
template<typename LFSUC>
void loadCoefficientsLFSUOutside(const LFSUC & lfsu_n_cache){
global_sn_view.read(xn);
global_zn_view.read(zn);
}
template<typename LFSUC>
void loadCoefficientsLFSUCoupling(const LFSUC & lfsu_c_cache)
{DUNE_THROW(Dune::NotImplemented,"No coupling lfsu available for ");}
//! @}
//! Notifier functions, called immediately before and after assembling
//! @{
void postAssembly(const GFSU& gfsu, const GFSV& gfsv){
if(local_assembler.doPostProcessing){
Dune::PDELab::constrain_residual(*(local_assembler.pconstraintsv),global_rl_view.container());
}
}
//! @}
//! Assembling methods
//! @{
/** Assemble on a given cell without function spaces.
\return If true, the assembling for this cell is assumed to
be complete and the assembler continues with the next grid
cell.
*/
template<typename EG>
bool assembleCell(const EG & eg)
{
return LocalAssembler::isNonOverlapping && eg.entity().partitionType() != Dune::InteriorEntity;
}
template<typename EG, typename LFSUC, typename LFSVC>
void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
{
rl_view.setWeight(local_assembler.weight);
Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolume>::
nonlinear_jacobian_apply_volume(lop,eg,lfsu_cache.localFunctionSpace(),xl,zl,lfsv_cache.localFunctionSpace(),rl_view);
}
template<typename IG, typename LFSUC, typename LFSVC>
void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
{
rl_view.setWeight(local_assembler.weight);
rn_view.setWeight(local_assembler.weight);
Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaSkeleton>::
nonlinear_jacobian_apply_skeleton(lop,ig,
lfsu_s_cache.localFunctionSpace(),xl,zl,lfsv_s_cache.localFunctionSpace(),
lfsu_n_cache.localFunctionSpace(),xn,zn,lfsv_n_cache.localFunctionSpace(),
rl_view,rn_view);
}
template<typename IG, typename LFSUC, typename LFSVC>
void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
{
rl_view.setWeight(local_assembler.weight);
Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaBoundary>::
nonlinear_jacobian_apply_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),xl,zl,lfsv_s_cache.localFunctionSpace(),rl_view);
}
template<typename IG, typename LFSUC, typename LFSVC>
static void assembleUVEnrichedCoupling(const IG & ig,
const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
{DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");}
template<typename EG, typename LFSUC, typename LFSVC>
void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
{
rl_view.setWeight(local_assembler.weight);
Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolumePostSkeleton>::
nonlinear_jacobian_apply_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),xl,zl,lfsv_cache.localFunctionSpace(),rl_view);
}
//! @}
private:
//! Reference to the wrapping local assembler object which
//! constructed this engine
const LocalAssembler & local_assembler;
//! Reference to the local operator
const LOP & lop;
//! Pointer to the current residual vector in which to assemble
ResidualView global_rl_view;
ResidualView global_rn_view;
//! Pointer to the current residual vector in which to assemble
SolutionView global_sl_view;
SolutionView global_sn_view;
//! Pointer to the current residual vector in which to assemble
SolutionView global_zl_view;
SolutionView global_zn_view;
//! The local vectors and matrices as required for assembling
//! @{
typedef Dune::PDELab::TrialSpaceTag LocalTrialSpaceTag;
typedef Dune::PDELab::TestSpaceTag LocalTestSpaceTag;
typedef Dune::PDELab::LocalVector<SolutionElement, LocalTrialSpaceTag> SolutionVector;
typedef Dune::PDELab::LocalVector<ResidualElement, LocalTestSpaceTag> ResidualVector;
//! Inside local coefficients
SolutionVector xl;
//! Outside local coefficients
SolutionVector xn;
//! Inside local coefficients
SolutionVector zl;
//! Outside local coefficients
SolutionVector zn;
//! Inside local residual
ResidualVector rl;
//! Outside local residual
ResidualVector rn;
//! Inside local residual weighted view
typename ResidualVector::WeightedAccumulationView rl_view;
//! Outside local residual weighted view
typename ResidualVector::WeightedAccumulationView rn_view;
//! @}
}; // End of class DefaultLocalJacobianAssemblerEngine
}
}
#endif // DUNE_PDELAB_GRIDOPERATOR_DEFAULT_NONLINEARJACOBIANAPPLYENGINE_HH
|