|
dune-fem 2.12-git
|
Loading...
Searching...
No Matches
amgistl.hh
Go to the documentation of this file.
88 using VectorType = std::decay_t< decltype( std::declval< const DiscreteFunction & >().dofVector().array() ) >;
104 typedef Dune::BCRSMatrix< typename Dune::Fem::ISTLLinearOperator< DomainFunction, RangeFunction >::LittleBlockType > Type;
133 explicit FemCommunication ( const DiscreteFunctionSpaceType &dfSpace, Dune::SolverCategory::Category solverCategory = Dune::SolverCategory::sequential )
137 const typename DiscreteFunctionSpace::GridPartType::CommunicationType &communicator () const { return dfSpace_.gridPart().comm(); }
143 typedef Dune::Fem::HierarchicalDiscreteFunction< DiscreteFunctionSpaceType > DiscreteFunctionType;
144 DiscreteFunctionType z( "", dfSpace_, reinterpret_cast< typename DiscreteFunctionType::DofVectorType & >( y ) );
203 BuildRemoteIndicesDataHandle ( int rank, const Mapper &mapper, const GlobalLookup &globalLookup )
272 typedef typename Dune::OwnerOverlapCopyCommunication< GlobalId, LocalId >::GlobalLookupIndexSet GlobalLookupType;
276 communication.reset( new Dune::OwnerOverlapCopyCommunication< GlobalId, LocalId >( solverCategory ) );
282 Dune::Fem::ParallelDofMapper< GridPartType, LocalMapperType, GlobalId > globalMapper( gridPart, localMapper );
285 std::vector< typename LocalIndexType::Attribute > attribute( localMapper.size(), Dune::OwnerOverlapCopyAttributeSet::owner );
292 communication->indexSet().add( globalMapper.mapping()[ i ], LocalIndexType( i, attribute[ i ] ) );
297 BuildRemoteIndicesDataHandle< LocalMapperType, GlobalLookupType > buildRemoteIndicesDataHandle( gridPart.comm().rank(), localMapper, communication->globalLookup() );
298 gridPart.communicate( buildRemoteIndicesDataHandle, Dune::All_All_Interface, Dune::ForwardCommunication );
301 communication->remoteIndices().setIndexSets( communication->indexSet(), communication->indexSet(), communication->communicator() );
306 std::sort( remote.second.begin(), remote.second.end(), [] ( const auto &a, const auto &b ) { return (a.localIndexPair().global() < b.localIndexPair().global()); } );
307 auto modifier = communication->remoteIndices().template getModifier< false, true >( remote.first );
337 void getEnum ( const Dune::Fem::ParameterReader ¶meter, const std::string &key, const std::tuple< NamedType< T >... > &types, const std::string &defaultValue, F &&f )
341 Dune::Hybrid::forEach( std::index_sequence_for< T... >(), [ &types, &f, &value, &success ] ( auto &&i ) -> void {
356 void getEnum ( const std::string &key, const std::tuple< NamedType< T >... > &types, const std::string &defaultValue, F &&f )
367 inline std::shared_ptr< Dune::Preconditioner< typename AssembledOperator::domain_type, typename AssembledOperator::range_type > >
368 makePreconditioner ( const std::shared_ptr< AssembledOperator > op, const Communication &comm, Symmetry symmetry )
373 typedef typename Dune::FieldTraits< typename AssembledOperator::field_type >::real_type real_type;
376 smootherArgs.relaxationFactor = Dune::Fem::Parameter::getValue( "istl.preconditioner.relax", real_type( 1 ) );
378 const auto smootherTypes = std::make_tuple( NamedType< Dune::SeqJac < matrix_type, domain_type, range_type > >( "jacobi" ),
389 auto sp = std::make_shared< Dune::Richardson< domain_type, range_type > >( smootherArgs.relaxationFactor );
390 auto *bp = new Dune::BlockPreconditioner< domain_type, range_type, Communication, std::decay_t< decltype( *sp ) > >( *sp, comm );
396 getEnum( "istl.preconditioner.smoother", smootherTypes, "jacobi", [ op, &comm, &smootherArgs, &preconditioner ] ( auto namedType ) {
397 typedef Dune::BlockPreconditioner< domain_type, range_type, Communication, typename decltype( namedType )::Type > SmootherType;
405 preconditioner.reset( ConstructionTraits::construct( args ), [ op ] ( SmootherType *p ) { ConstructionTraits::deconstruct( p ); } );
410 getEnum( "istl.preconditioner.smoother", smootherTypes, "jacobi", [ op, &comm, symmetry, &smootherArgs, &preconditioner ] ( auto namedType ) {
411 typedef Dune::BlockPreconditioner< domain_type, range_type, Communication, typename decltype( namedType )::Type > SmootherType;
416 amgParams.setMaxLevel( Dune::Fem::Parameter::getValue( "istl.preconditioner.amg.maxlevel", 100 ) );
417 amgParams.setCoarsenTarget( Dune::Fem::Parameter::getValue( "istl.preconditioner.amg.coarsentarget", 1000 ) );
418 amgParams.setMinCoarsenRate( Dune::Fem::Parameter::getValue( "istl.preconditioner.amg.mincoarsenrate", 1.2 ) );
420 amgParams.setAccumulate( static_cast< Dune::Amg::AccumulationMode >( Dune::Fem::Parameter::getEnum( "istl.preconditioner.amg.accumulate", accumulationModeNames, 2 ) ) );
421 amgParams.setProlongationDampingFactor( Dune::Fem::Parameter::getValue( "istl.preconditioner.amg.prolongation.dampingfactor", 1.6 ) );
424 amgParams.setDebugLevel( Dune::Fem::Parameter::getValue( "istl.preconditioner.amg.debuglevel", 0 ) );
425 amgParams.setNoPreSmoothSteps( Dune::Fem::Parameter::getValue< std::size_t >( "istl.preconditioner.amg.presmoothsteps", 2 ) );
426 amgParams.setNoPostSmoothSteps( Dune::Fem::Parameter::getValue< std::size_t >( "istl.preconditioner.amg.postsmoothsteps", 2 ) );
428 amgParams.setGamma( 1 + Dune::Fem::Parameter::getEnum( "istl.preconditioner.amg.cycle", cycleNames, 0 ) );
429 amgParams.setAdditive( Dune::Fem::Parameter::getValue( "istl.preconditioner.amg.additive", false ) );
434 Dune::Amg::CoarsenCriterion< Dune::Amg::SymmetricCriterion< matrix_type, Dune::Amg::RowSum > > criterion( amgParams );
435 preconditioner.reset( new AMG( *op, criterion, smootherArgs, comm ), [ op ] ( AMG *p ) { delete p; } );
439 Dune::Amg::CoarsenCriterion< Dune::Amg::UnSymmetricCriterion< matrix_type, Dune::Amg::RowSum > > criterion( amgParams );
440 preconditioner.reset( new AMG( *op, criterion, smootherArgs, comm ), [ op ] ( AMG *p ) { delete p; } );
458 : public Dune::Fem::Operator< typename LinearOperator::RangeFunctionType, typename LinearOperator::DomainFunctionType >
460 static_assert( std::is_same< typename LinearOperator::DomainFunctionType, typename LinearOperator::RangeFunctionType >::value, "Domain function and range function must have the same type." );
470 typedef typename Dune::FieldTraits< typename DiscreteFunctionType::RangeFieldType >::real_type RealType;
480 typedef Dune::OwnerOverlapCopyCommunication< std::size_t, typename DiscreteFunctionSpaceType::BlockMapperType::GlobalKeyType > CommunicationType;
482 typedef Dune::OverlappingSchwarzOperator< matrix_type, vector_type, vector_type, CommunicationType > AssembledLinearOperatorType;
486 typedef std::function< std::shared_ptr< PreconditionerType > ( std::shared_ptr< AssembledLinearOperatorType >, const CommunicationType &, Symmetry ) > PreconditionerFactory;
488 InverseOperator ( PreconditionerFactory preconditionerFactory, RealType redEps, RealType absLimit, int maxIterations )
494 : InverseOperator( makePreconditioner< AssembledLinearOperatorType, CommunicationType >, redEps, absLimit, maxIterations )
497 InverseOperator ( RealType redEps, RealType absLimit, int maxIterations, bool verbose, const Dune::Fem::SolverParameter& parameter )
501 InverseOperator ( PreconditionerFactory preconditionerFactory, RealType redEps, RealType absLimit )
502 : InverseOperator( std::move( preconditionerFactory ), redEps, absLimit, std::numeric_limits< int >::max() )
519 InverseOperator ( const SolverParameter& parameter = SolverParameter( Parameter::container() ) )
546 scalarProduct_.reset( new Dune::OverlappingSchwarzScalarProduct< vector_type, CommunicationType >( *communication_ ) );
564 switch( Dune::Fem::Parameter::getEnum( "istl.solver.type", solverTypes, (symmetry == symmetric ? 0 : 3) ) )
567 solver_.reset( new Dune::CGSolver< vector_type >( *linearOperator_, *scalarProduct_, *preconditioner_, redEps_, maxIterations_, verbosity ) );
573 solver_.reset( new Dune::GeneralizedPCGSolver< vector_type >( *linearOperator_, *scalarProduct_, *preconditioner_, redEps_, maxIterations_, verbosity, restart ) );
578 solver_.reset( new Dune::MINRESSolver< vector_type >( *linearOperator_, *scalarProduct_, *preconditioner_, redEps_, maxIterations_, verbosity ) );
582 solver_.reset( new Dune::BiCGSTABSolver< vector_type >( *linearOperator_, *scalarProduct_, *preconditioner_, redEps_, maxIterations_, verbosity ) );
588 solver_.reset( new Dune::RestartedGMResSolver< vector_type >( *linearOperator_, *scalarProduct_, *preconditioner_, redEps_, restart, maxIterations_, verbosity ) );
const char * name()
static std::shared_ptr< T > construct(Arguments &)
AMG(OperatorHierarchy &matrices, CoarseSolver &coarseSolver, const SmootherArgs &smootherArgs, const Parameters &parms)
void setMaxLevel(int l)
const void * Arguments
AccumulationMode
RelaxationFactor relaxationFactor
Singleton< ParameterizedObjectFactory< PreconditionerSignature< OP > > > PreconditionerFactory
symmetric
int size() const
void insert(const T &v)
constexpr void forEach(Range &&range, F &&f)
constexpr auto max
size_type dim() const
static constexpr size_type M()
std::ptrdiff_t index() const
virtual void operator()()=0
#define DUNE_THROW(E,...)
const IndexPair * pair(const std::size_t &local) const
RemoteIndex & remoteIndex() const
const Attribute attribute() const
GlobalLookupIndexSet(const ParallelIndexSet &indexset, std::size_t size)
ForwardCommunication
All_All_Interface
const Communication & comm() const
STL namespace.
void buildCommunication(const DiscreteFunctionSpace &dfSpace, Dune::SolverCategory::Category solverCategory, std::shared_ptr< FemCommunication< DiscreteFunctionSpace > > &communication)
Definition fem.hh:143
T real_type
int iterations
Category
sequential
overlapping
GridImp::template Codim< cd >::Entity Entity
bool contains(const EntityType &e, IndexType &result) const
Definition hierarchical/function.hh:106
static ParameterContainer & container()
Definition io/parameter.hh:199
static T getValue(const std::string &key)
get a mandatory parameter from the container
Definition io/parameter.hh:344
static int getEnum(const std::string &key, const std::string(&values)[n])
Definition io/parameter.hh:400
Definition io/parameter/exceptions.hh:26
T getValue(const std::string &key) const
get mandatory parameter
Definition reader.hh:161
FemCommunication(const DiscreteFunctionSpaceType &dfSpace, Dune::SolverCategory::Category solverCategory=Dune::SolverCategory::sequential)
Definition fem.hh:80
DiscreteFunctionSpace DiscreteFunctionSpaceType
Definition fem.hh:78
void dot(const T &x, const T &y, F &scp) const
Definition fem.hh:106
Dune::FieldTraits< typenameT::field_type >::real_type norm(const T &x) const
Definition fem.hh:122
Dune::SolverCategory::Category getSolverCategory() const
Definition fem.hh:130
const DiscreteFunctionSpace::GridPartType::CommunicationType & communicator() const
Definition fem.hh:84
void copyOwnerToAll(const T &x, T &y) const
Definition fem.hh:87
GlobalLookup::LocalIndex::Attribute AttributeType
Definition owneroverlapcopy.hh:46
void gather(Buffer &buffer, const Entity &entity) const
Definition owneroverlapcopy.hh:56
BuildRemoteIndicesDataHandle(int rank, const Mapper &mapper, const GlobalLookup &globalLookup)
Definition owneroverlapcopy.hh:48
bool contains(int dim, int codim) const
Definition owneroverlapcopy.hh:52
std::map< int, std::vector< Dune::RemoteIndex< GlobalIndexType, AttributeType > > > remotes
Definition owneroverlapcopy.hh:88
GlobalLookup::GlobalIndex GlobalIndexType
Definition owneroverlapcopy.hh:45
void scatter(Buffer &buffer, const Entity &entity, std::size_t n)
Definition owneroverlapcopy.hh:69
bool fixedSize(int dim, int codim) const
Definition owneroverlapcopy.hh:53
Definition solver/parameter.hh:25
Definition parallel.hh:87
discrete function space
T bind(T... args)
T copy(T... args)
T forward(T... args)
T make_tuple(T... args)
T max(T... args)
T move(T... args)
T reset(T... args)
T sort(T... args)
T sqrt(T... args)
Legal Statements / Impressum | Hosted by TU Dresden & Uni Heidelberg | Generated by
1.9.8