DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_BasicGeometryManager.cpp
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #include "DTK_BasicGeometryManager.hpp"
42 #include "DTK_BasicEntityPredicates.hpp"
43 #include "DTK_BasicEntitySet.hpp"
44 #include "DTK_BasicGeometryLocalMap.hpp"
45 #include "DTK_DBC.hpp"
46 #include "DTK_EntityCenteredShapeFunction.hpp"
47 #include "DTK_PredicateComposition.hpp"
48 
49 namespace DataTransferKit
50 {
51 //---------------------------------------------------------------------------//
54  const Teuchos::RCP<const Teuchos::Comm<int>> comm,
55  const int physical_dimension )
56 {
57  Teuchos::Array<Entity> entities( 0 );
58  createFunctionSpace( comm, physical_dimension, entities,
59  FunctionSpace::selectAll );
60  DTK_ENSURE( Teuchos::nonnull( d_function_space ) );
61 }
62 
63 //---------------------------------------------------------------------------//
66  const Teuchos::RCP<const Teuchos::Comm<int>> comm,
67  const int physical_dimension, const Teuchos::ArrayView<Entity> &entities )
68 {
69  createFunctionSpace( comm, physical_dimension, entities,
70  FunctionSpace::selectAll );
71  DTK_ENSURE( Teuchos::nonnull( d_function_space ) );
72 }
73 
74 //---------------------------------------------------------------------------//
77  const Teuchos::RCP<const Teuchos::Comm<int>> comm,
78  const int physical_dimension, const Teuchos::ArrayView<Entity> &entities,
79  const Teuchos::ArrayView<int> &block_ids,
80  const Teuchos::ArrayView<int> &boundary_ids )
81 {
82  Teuchos::Array<int> block_array( block_ids );
83  Teuchos::Array<int> boundary_array( boundary_ids );
84  BlockPredicate block_pred( block_array );
85  BoundaryPredicate boundary_pred( boundary_array );
86  PredicateFunction pred = PredicateComposition::Or(
87  block_pred.getFunction(), boundary_pred.getFunction() );
88  createFunctionSpace( comm, physical_dimension, entities, pred );
89  DTK_ENSURE( Teuchos::nonnull( d_function_space ) );
90 }
91 
92 //---------------------------------------------------------------------------//
93 // Get the function space over which the mesh and its fields are defined.
94 Teuchos::RCP<FunctionSpace> BasicGeometryManager::functionSpace() const
95 {
96  return d_function_space;
97 }
98 
99 //---------------------------------------------------------------------------//
100 // Create the function space.
101 void BasicGeometryManager::createFunctionSpace(
102  const Teuchos::RCP<const Teuchos::Comm<int>> comm,
103  const int physical_dimension, const Teuchos::ArrayView<Entity> &entities,
104  const PredicateFunction &select_function )
105 {
106  Teuchos::RCP<BasicEntitySet> entity_set =
107  Teuchos::rcp( new BasicEntitySet( comm, physical_dimension ) );
108  for ( Entity e : entities )
109  {
110  entity_set->addEntity( e );
111  }
112 
113  Teuchos::RCP<EntityLocalMap> local_map =
114  Teuchos::rcp( new BasicGeometryLocalMap() );
115 
116  Teuchos::RCP<EntityShapeFunction> shape_function =
117  Teuchos::rcp( new EntityCenteredShapeFunction() );
118 
119  d_function_space =
120  Teuchos::rcp( new FunctionSpace( entity_set, local_map, shape_function,
121  Teuchos::null, select_function ) );
122 }
123 
124 //---------------------------------------------------------------------------//
125 
126 } // end namespace DataTransferKit
127 
128 //---------------------------------------------------------------------------//
129 // end DTK_BasicGeometryManager.cpp
130 //---------------------------------------------------------------------------//
BasicGeometryManager(const Teuchos::RCP< const Teuchos::Comm< int >> comm, const int physical_dimension)
Default constructor. Initializes an empty entity set with a function space defined over the given typ...
Geometric entity interface definition.
Definition: DTK_Entity.hpp:61
Assertions and Design-by-Contract for error handling.
std::function< bool(Entity)> PredicateFunction
Predicate function typedef.
Definition: DTK_Types.hpp:64
Entity forward and reverse local map interface definition.
Basic implementation of the entity set interface.
DTK_BasicEntitySet.cpp.
Teuchos::RCP< FunctionSpace > functionSpace() const
Get the function space over which the mesh and its fields are defined.