45 #include <Epetra_ConfigDefs.h> 48 #include <Epetra_MpiComm.h> 50 #include <Epetra_SerialComm.h> 54 #include <lifev/core/LifeV.hpp> 56 #include <lifev/core/filter/GetPot.hpp> 58 #include <lifev/core/mesh/RegionMesh.hpp> 59 #include <lifev/core/mesh/RegionMesh2DStructured.hpp> 60 #include <lifev/core/mesh/MeshEntityContainer.hpp> 62 using namespace LifeV;
74 template <
typename MeshEntityType,
75 typename ComparisonPolicyType =
std::
function <
bool (
98 barycenter += entity.point ( k ).coordinates();
116 template <
typename MeshEntityType >
128 std::vector<Real> sign ( meshEntity_Type::S_numPoints );
131 sign[ k ] = M_distanceFunction ( entity.point ( k ).coordinates() );
138 if ( sign[ i ] * sign[ j ] < 0. )
175 int main (
int argc,
char** argv )
182 MPI_Init (&argc, &argv);
183 std::shared_ptr<Epetra_Comm> comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
184 verbose = comm->MyPID() == 0;
186 std::shared_ptr<Epetra_Comm> comm (
new Epetra_SerialComm );
190 const UInt numMeshElem = 3;
193 meshPtr_Type mesh (
new mesh_Type ( comm ) );
196 regularMesh2D ( *mesh,
198 numMeshElem, numMeshElem,
206 CircleInterrogator<mesh_Type::element_Type> myCircleInterrogator ( Vector3D ( 0.5, 0.5, 0.0 ), 0.25 );
209 UInt numExtractedElements = mesh->elementList().countAccordingToPredicate ( myCircleInterrogator );
210 if ( verbose ) std::cout <<
"the number of elements that stay inside the circle is " 211 << numExtractedElements << std::endl;
213 std::vector<mesh_Type::element_Type
const*> extractedElements ( numExtractedElements );
216 extractedElements = mesh->elementList().extractAccordingToPredicate ( myCircleInterrogator );
219 std::cout <<
"the elements ids are: ";
221 for ( UInt k = 0; k < numExtractedElements; k++ )
225 std::cout << extractedElements[ k ]->id() <<
" ";
230 std::cout << std::endl;
239 lineDistance myLine ( 1., 1., -1.1 );
242 LevelSetInterrogator<mesh_Type::facet_Type> myLevelSetInterrogator ( myLine );
245 UInt numExtractedFacets = mesh->facetList().countAccordingToPredicate ( myLevelSetInterrogator );
246 if ( verbose ) std::cout <<
"the number of facets that are crossed by the level set is " 247 << numExtractedFacets << std::endl;
249 std::vector<mesh_Type::facet_Type
const*> extractedFacets ( numExtractedFacets );
252 extractedFacets = mesh->facetList().extractAccordingToPredicate ( myLevelSetInterrogator );
255 std::cout <<
"the facets ids are: ";
257 for ( UInt k = 0; k < numExtractedFacets; k++ )
261 std::cout << extractedFacets[ k ]->id() <<
" ";
266 std::cout << std::endl;
275 return ( EXIT_SUCCESS );
Real operator()(Vector3D const &point)
std::shared_ptr< mesh_Type > meshPtr_Type
bool operator()(meshEntity_Type const &entity) const
bool operator()(const meshEntity_Type &entity) const
RegionMesh< LinearTriangle > mesh_Type
Real const & operator[](UInt const &i) const
Operator [].
distanceFunction_Type M_distanceFunction
MeshEntityType meshEntity_Type
std::function< Real(Vector3D const &) > distanceFunction_Type
CircleInterrogator(Vector3D const ¢er, Real radius, comparisonPolicy_Type const &policy=std::less< Real >())
VectorSmall(VectorSmall< 3 > const &vector)
Copy constructor.
MeshEntityType meshEntity_Type
const comparisonPolicy_Type M_policy
double Real
Generic real data.
VectorSmall< 3 > Vector3D
ComparisonPolicyType comparisonPolicy_Type
int main(int argc, char **argv)
lineDistance(Real a, Real b, Real c)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
LevelSetInterrogator(distanceFunction_Type const &distFun)