41 #ifndef DTK_NODETONODE_IMPL_HPP 42 #define DTK_NODETONODE_IMPL_HPP 44 #include "DTK_BasicEntityPredicates.hpp" 49 #include "DTK_PredicateComposition.hpp" 52 #include <Teuchos_ArrayRCP.hpp> 53 #include <Teuchos_CommHelpers.hpp> 54 #include <Teuchos_ParameterList.hpp> 55 #include <Teuchos_Ptr.hpp> 57 #include <Tpetra_MultiVector.hpp> 65 const Teuchos::RCP<const TpetraMap> &domain_map,
66 const Teuchos::RCP<const TpetraMap> &range_map,
67 const Teuchos::ParameterList ¶meters )
68 :
Base( domain_map, range_map )
76 const Teuchos::RCP<FunctionSpace> &domain_space,
77 const Teuchos::RCP<FunctionSpace> &range_space )
79 DTK_REQUIRE( Teuchos::nonnull( domain_space ) );
80 DTK_REQUIRE( Teuchos::nonnull( range_space ) );
83 const Teuchos::RCP<const typename Base::TpetraMap> domain_map =
85 const Teuchos::RCP<const typename Base::TpetraMap> range_map =
89 Teuchos::RCP<const Teuchos::Comm<int>> comm = domain_map->getComm();
92 bool nonnull_domain = Teuchos::nonnull( domain_space->entitySet() );
93 bool nonnull_range = Teuchos::nonnull( range_space->entitySet() );
96 Teuchos::ArrayRCP<double> source_centers;
97 Teuchos::ArrayRCP<GO> source_support_ids;
98 getNodeCoordsAndIds( domain_space, source_centers, source_support_ids );
101 Teuchos::ArrayRCP<double> target_centers;
102 Teuchos::ArrayRCP<GO> target_support_ids;
103 getNodeCoordsAndIds( range_space, target_centers, target_support_ids );
107 Teuchos::Array<double> dist_sources;
109 comm, source_centers(), target_centers(), 1.0e-3, dist_sources );
114 Teuchos::Array<GO> dist_source_support_ids( distributor.getNumImports() );
115 Teuchos::ArrayView<const GO> source_support_ids_view = source_support_ids();
116 distributor.
distribute( source_support_ids_view,
117 dist_source_support_ids() );
126 Teuchos::rcp(
new Tpetra::CrsMatrix<Scalar, LO, GO>( range_map, 1 ) );
127 Teuchos::Array<GO> indices( 1 );
128 Teuchos::Array<double> values( 1, 1.0 );
130 int local_num_tgt = target_support_ids.size();
131 for (
int i = 0; i < local_num_tgt; ++i )
145 target_centers( DIM * i, DIM ).getRawPtr() ) ) < 1.0e-14 );
152 d_coupling_matrix->insertGlobalValues( target_support_ids[i],
153 indices(), values() );
156 d_coupling_matrix->fillComplete( domain_map, range_map );
157 DTK_ENSURE( d_coupling_matrix->isFillComplete() );
164 TpetraMultiVector &Y,
165 Teuchos::ETransp mode,
double alpha,
168 d_coupling_matrix->apply( X, Y, mode, alpha, beta );
183 const Teuchos::RCP<FunctionSpace> &space,
184 Teuchos::ArrayRCP<double> ¢ers,
185 Teuchos::ArrayRCP<GO> &support_ids )
const 189 if ( Teuchos::nonnull( space->entitySet() ) )
191 LocalEntityPredicate local_predicate(
192 space->entitySet()->communicator()->getRank() );
194 space->selectFunction(), local_predicate.getFunction() );
195 iterator = space->entitySet()->entityIterator( 0, predicate );
199 int local_num_node = iterator.size();
200 centers = Teuchos::ArrayRCP<double>( DIM * local_num_node );
201 support_ids = Teuchos::ArrayRCP<GO>( local_num_node );
202 Teuchos::Array<SupportId> node_supports;
205 int entity_counter = 0;
207 ++entity, ++entity_counter )
209 space->shapeFunction()->entitySupportIds( *entity, node_supports );
210 DTK_CHECK( 1 == node_supports.size() );
211 support_ids[entity_counter] = node_supports[0];
212 space->localMap()->centroid( *entity,
213 centers( DIM * entity_counter, DIM ) );
223 #endif // end DTK_NODETONODE_IMPL_HPP Local source/parent center pairings.
NodeToNodeOperator(const Teuchos::RCP< const TpetraMap > &domain_map, const Teuchos::RCP< const TpetraMap > &range_map, const Teuchos::ParameterList ¶meters)
Constructor.
Entity iterator interface.
MapOperator Base
Typedefs.
Parallel node-to-node transfer.
Assertions and Design-by-Contract for error handling.
Eucliden distance function.
std::function< bool(Entity)> PredicateFunction
Predicate function typedef.
Global source distributor.
Teuchos::ArrayView< const unsigned > childCenterIds(const unsigned parent_id) const
Given a parent center local id get the ids of the child centers within the given radius.
Global center distributor.
Euclidean distance function.
Local child/parent center pairings.
void distribute(const Teuchos::ArrayView< const T > &source_decomp_data, const Teuchos::ArrayView< T > &target_decomp_data) const
Given a set of scalar values at the given source centers in the source decomposition, distribute them to the target decomposition.
void applyImpl(const TpetraMultiVector &X, TpetraMultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, double alpha=Teuchos::ScalarTraits< double >::one(), double beta=Teuchos::ScalarTraits< double >::zero()) const override
Apply the operator.
Parallel moving least square interpolator MapOperator implementation.