From 67ec7dc3f3d263ae02d96c7afb1df4ea80d2ef5f Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 4 Jul 2012 12:18:02 +0000 Subject: [PATCH] Docs refactoring. --- doc/doxygen/medcoupling.dox | 501 +++++++++--------- doc/doxygen/medcouplingexamples.doxy | 50 ++ .../Test/MEDCouplingExamplesTest.cxx | 69 +++ .../MEDCouplingExamplesTest.py | 49 ++ 4 files changed, 421 insertions(+), 248 deletions(-) diff --git a/doc/doxygen/medcoupling.dox b/doc/doxygen/medcoupling.dox index 5ec89d0d0..f3805cd07 100644 --- a/doc/doxygen/medcoupling.dox +++ b/doc/doxygen/medcoupling.dox @@ -3,79 +3,152 @@ \section MEDCouplingIntro Introduction -The MEDCoupling module is presented under the form of a library -libmedcoupling and interfaces. This module MEDCoupling represents the -DataStructure designed to be exchanged by processors as well in -parallel case in SPMD paradigm ( \ref paramedmem "ParaMEDMEM" ), as in -distributed paradigm using CORBA. This DataStructure is \b fully -deconnected from \ref medmem "MEDMEM". This DataStructure is light in -order to minimize as much as possible the number of prerequisites needed -to use it. The idea is that as this DataStructure is intended to be -linked with all of code candidate for coupling ; the number of -prerequisites of medcoupling has to be threfore tiny. MEDCoupling has -been developped to comply with ICOCO API, \ref interpkernel -"conservative interpolators" and VTK visualization -DataStructure. The MEDCoupling DataStructures have been -developped to be compatible with HPC constraints (compact structures, -limitation of copies and launching of CPU consuming algorithms only when -absolutely needed ). - -\section MEDCouplingMainBasics Basics +\ref medcoupling "MEDCoupling" is a library (\b libmedcoupling.so or \b medcoupling.dll) fully written in C++ and wrapped to be called in Python too. -One of the most basic concept mainly used all over MEDCoupling is -MEDCoupling array. This concept is used all over -MEDCoupling/ParaMEDMEM/MEDLoader modules so it should be correctly -handled to play well with \ref MEDCouplingMeshesP "Meshes" and \ref MEDCouplingFieldsP "Fields". +\ref medcoupling "MEDCoupling" C++ library implements a data structure which is the result of the following tradeoff : + +- Compliant with coupling : + - Fields definition defined enough to perform well defined interpolation + - exchangeable through process as well in parallel case in SPMD paradigm ( \ref paramedmem "ParaMEDMEM" ), as in distributed paradigm using CORBA. +- minimize as much as possible the number of prerequisites needed to use it ; So \ref medcoupling "MEDCoupling" only depends from +\ref interpkernel "INTERP_KERNEL library" +- light enough to be agile in order to : + - maximize the amount of algorithms being applied on it + - to ease implementation of clients of \ref medcoupling "MEDCoupling". +- large enough to be used for MED file I/O. +- compliant with VTK visualization DataStructure +- integrate HPC constraints (compact structures, limitation of copies and launching of CPU consuming algorithms only when absolutely needed ). +- compliant with ICOCO API -There are two types of arrays : - - double precision float array incarnated by ParaMEDMEM::DataArrayDouble class. - - integer array incarnated by ParaMEDMEM::DataArrayInt class. +The \ref medcoupling "MEDCoupling" data structure is \b fully \b independant from those implemented in MEDMEM. -To learn more about arrays \ref MEDCouplingArrayPage "click here for arrays documentation". +\ref medcoupling "MEDCoupling" implements a set of algorithms linked to the data structure. \section MEDCouplingMainConc Main Concepts -- \ref MEDCouplingMeshesP "Meshes" -- \ref MEDCouplingFieldsP "Fields" +Here are listed basic concepts present into \ref medcoupling "MEDCoupling". -\section MEDCouplingFirstSteps2 Building unstructured mesh from scratch +For beginners in \ref medcoupling "MEDCoupling" world, it is advisable to read the following concepts in the same order than the underlying list. -All of exemples given here make the assumption that the \c ParaMEDMEM -namespace is visible ( by calling for example \c using \c -namespace \c ParaMEDMEM; ). +- \subpage MEDCouplingArrayPage "DataArrays" +- \subpage MEDCouplingMeshesPage "Meshes" +- \subpage MEDCouplingFieldsPage "Fields" +- \subpage MEDCouplingFieldTemplatesPage "Field templates" -Here we will create a mesh with spacedim==2 and meshdim==2 too with 5 -cells and 9 nodes. +*/ -You can notice that it is possible to mix cell -types as long as the dimension of cell is exactly equal to -meshDim to respect \ref MEDCouplingMeshes "this rule". +/*! + \page MEDCouplingMeshesPage Meshes in MEDCoupling -\code +\section MEDCouplingMeshes Common concept shared by all type of Meshes in MEDCoupling -double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; -int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4}; -MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); -mesh->setName("My2DMesh"); -mesh->setMeshDimension(2); -mesh->allocateCells(5);//You can put more than 5 if you want but not less. -mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); -mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+4); -mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+7); -mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); -mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); -mesh->finishInsertingCells(); -DataArrayDouble *myCoords=DataArrayDouble::New(); -myCoords->alloc(9,2);//here myCoords are declared to have 2 components, mesh will deduce that spaceDim==2 -std::copy(coords,coords+18,myCoords->getPointer()); -mesh->setCoords(myCoords); -myCoords->decrRef(); -//mesh is now usable -... -//mesh is no more usefully here : release it -mesh->decrRef(); +A mesh has a the following properties : -\endcode +- name +- a dimension (called mesh dimension) and only one (it implies that \b all cells constituting +mesh have the same dimension) +- a space dimension (relative to coordinates) +- a number of nodes +- a number of cells + +In MEDCoupling library there is no presence of faces nor edges. + +As a mesh has one dimension and only once, that is to say every cells in +mesh have the same dimension called MeshDimension. + +That is to say the +MEDMEM vocabulary of faces and edges \b do \b not \b exist \b anymore here in +MEDCoupling. + +For exemple a mesh with a meshDimension equal to 1, have \b cells of type +NORM_SEG2. An another exemple, a mesh with a meshDimension equal +to 2, have \b cells of type +NORM_TRI3 and NORM_POLYGON for example. + +The class that incarnates the concept described above is : +\ref ParaMEDMEM::MEDCouplingMesh. + +\section MEDCouplingMeshesAvailInstan Available instaciable mesh types in MEDCoupling + +- \subpage MEDCouplingUMeshPage "Unstructured meshes" +- \subpage MEDCouplingCMeshPage "Cartesian meshes" +- \subpage MEDCouplingExtrudedPage "3D Extruded meshes" + +/*! +\page MEDCouplingFieldsPage Fields in MEDCoupling + +\section MEDCouplingFields Field concept + +A field in MEDCoupling point of view, is a structure that allows to +store a discretization of a physical value on a defined discretized spatial and +possibly temporal support. + +The spatial support is a \ref MEDCouplingMeshesPage "mesh". +A field is lying on an entity that will be specified by the spatial +discretization of the field. For exemple a field on node will lie on +all nodes of its mesh. + +A field on cell will lie on all cells of its mesh. + +Fields in MEDCoupling follow the two following rules : + +- A field will lie on \b ALL entities of its spatial support (\ref MEDCouplingMeshesPage "mesh"). +- A field has \b only \b one spatial support (\ref MEDCouplingMeshesPage "mesh") on its temporal support. + +The main properties of a field are : + +- name +- spatial support which is a \ref MEDCouplingMeshesPage "mesh" +- a \ref MEDCouplingSpatialDisc "spatial discretization" +- a description of intrinsic nature of the values of field (see \ref NatureOfField). This is important for conservative interpolation (see \ref TableNatureOfField). +- a temporal discretization that specifies, if it exists, the time interval on which the field is covering, and how. +- number of components + +This definition of field in MEDCoupling allows an instance of field to +know at any point inside its spatial-temporal support the value. + +The class that incarnates the concept described above is : \ref ParaMEDMEM::MEDCouplingFieldDouble. + +Some of most important implemented methods are : + +- \ref ParaMEDMEM::MEDCouplingFieldDouble::getNumberOfComponents "getNumberOfComponents" +- \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOn "getValueOn" +- \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc "applyFunc" +- \ref ParaMEDMEM::MEDCouplingFieldDouble::addFields "cross instances operations" +\section MEDCouplingSpatialDisc Spatial discretization concept + +This is the concept that makes the link, independantly from temporal +discretization, between the field and its spatial support(\ref MEDCouplingMeshesPage "mesh"). This +concept allows the field to make a check and interpretation of an +array of values given a spatial support (\ref MEDCouplingMeshesPage "mesh"). + +The abstract class that incarnates the concept is : \ref ParaMEDMEM::MEDCouplingFieldDiscretization. + +The most important pure virtual methods are : + +- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getNumberOfTuples "getnumberOfTuples" +- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOn "getValueOn" +- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField "getMeasureField" + +\section MEDCouplingTemporalDisc Temporal discretization concept + +This information allows, independantly from spatial discretization, to +associate a time interval, if it exists, on which the field will be +defined. This concept is able to give the value at any time of +the definition interval (if any). + +The abstract class \ref ParaMEDMEM::MEDCouplingTimeDiscretization +incarnates this described concept. + +This classes and its subclasses are responsible in storing the arrays +of the aggregating field. + +The most important methods are : + +- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setTime "setTime" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getTime "getTime" +- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArray "getArray" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setArray "setArray" +- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArraysForTime "getArraysForTime" +- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getValueForTime "getValueForTime" \section MEDCouplingFirstSteps3 Building a field from scratch @@ -183,190 +256,6 @@ f3->decrRef(); f4->decrRef(); f5->decrRef(); \endcode -*/ - -/*! - \page MEDCouplingMeshesP Meshes in MEDCoupling - -\section MEDCouplingMeshes Common concept shared by all type of Meshes - -A mesh has a the following properties : - -- name -- a dimension (called mesh dimension) and only one (it implies that \b all cells constituting -mesh have the same dimension) -- a space dimension (relative to coordinates) -- a number of nodes -- a number of cells - -In MEDCoupling library there is no presence of faces nor edges. - -As a mesh has one dimension and only once, that is to say every cells in -mesh have the same dimension called MeshDimension. - -That is to say the -MEDMEM vocabulary of faces and edges \b do \b not \b exist \b anymore here in -MEDCoupling. - -For exemple a mesh with a meshDimension equal to 1, have \b cells of type -NORM_SEG2. An another exemple, a mesh with a meshDimension equal -to 2, have \b cells of type -NORM_TRI3 and NORM_POLYGON for example. - -The class that incarnates the concept described above is : -\ref ParaMEDMEM::MEDCouplingMesh. - -\section MEDCouplingUMeshes Unstructured meshes - -An unstructured mesh is defined by : - -- a point clouds where the explicit -coordinates of each point must be specified. -- nodal connectivity that specifies for each cell, the points in the -previous point clouds that constitutes the cell. - -As unstructured mesh is dynamically defined enough, this struture is -used by MEDCoupling to instanciate degenerated meshes as : - -- points cloud only meshes. This type of mesh will have mesh dimension - == 0 -- abstract meshes containing only one cell that covers a potentially - infinite space. This abstract mesh is used as support of fields - containing only one integrated value. This is typically used to - represent fields used by system code. This type of mesh will have - mesh dimension equal to -1. - -The norm used for cells connectivity of different types, is the same as specified in MED file except -that connectivities are in represented in \b C \b format and \b not \b in -\b FORTRAN \b format ! - -The class in charge to dealt with the described concept is \ref -ParaMEDMEM::MEDCouplingUMesh. This class inherits -from \ref MEDCouplingPointSets "PointSet" abstract meshes. - -\section MEDCouplingPointSets PointSet - -This is a \b non \b instanciable class that deals with set of points without -any connectivity aspect. - -The class that incarnates this concept in -MEDCoupling is : \ref ParaMEDMEM::MEDCouplingPointSet. - -This class is in charge to perform whole or part of algorithms of -its subclasses (\ref -ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh" and \ref -ParaMEDMEM::MEDCouplingUMeshDesc "MEDCouplingUMeshDesc") for -factorization reasons. - -Some of most important implemented methods are : - -- \ref ParaMEDMEM::MEDCouplingPointSet::getSpaceDimension "getSpaceDimension" -- \ref ParaMEDMEM::MEDCouplingPointSet::getNumberOfNodes "getNumberOfNodes" -- \ref ParaMEDMEM::MEDCouplingPointSet::rotate "rotate" -- \ref ParaMEDMEM::MEDCouplingPointSet::translate "translate" -- \ref ParaMEDMEM::MEDCouplingPointSet::scale "scale" -- \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes "findCommonNodes" -- \ref ParaMEDMEM::MEDCouplingPointSet::renumberNodes "renumberNodes" -- \ref ParaMEDMEM::MEDCouplingPointSet::getBoundingBox "getBoundingBox" - -\section MEDCouplingCMeshs Cartesian Mesh - -A cartesian mesh is a mesh that represents structured mesh whose nodes -are arranged along axes of trihedron. To instanciate an object of this -type, only n arrays are needed. In this type of mesh space dimension -\b and mesh dimension are equals and the value is n. The n arrays will have only one component and the values -contained in these arrays will be ascendantly sorted. - -The class that incarnates this concept in MEDCoupling is : \ref ParaMEDMEM::MEDCouplingCMesh. - -\section MEDCouplingExtrudedMeshes Extruded Mesh - -An extruded mesh is a mesh also called 2.5 D. It a convolution of 2D -unstructured mesh with 1D unstructured mesh. The problem is that this -type of mesh is not managed by any file format that's why to build an -instance of this mesh you need 3D unstructured mesh and a 2D -unstructured mesh lying on the same coordinates. The advantage of this -structure is that the interpolation time is optimized. - -The class that incarnates this concept in MEDCoupling is : \ref ParaMEDMEM::MEDCouplingExtrudedMesh. -*/ - -/*! -\page MEDCouplingFieldsP Fields in MEDCoupling - -\section MEDCouplingFields Field concept - -A field in MEDCoupling point of view, is a structure that allows to -store a discretization of a physical value on a defined discretized spatial and -possibly temporal support. - -The spatial support is a \ref MEDCouplingMeshesP "mesh". -A field is lying on an entity that will be specified by the spatial -discretization of the field. For exemple a field on node will lie on -all nodes of its mesh. - -A field on cell will lie on all cells of its mesh. - -Fields in MEDCoupling follow the two following rules : - -- A field will lie on \b ALL entities of its spatial support (\ref MEDCouplingMeshesP "mesh"). -- A field has \b only \b one spatial support (\ref MEDCouplingMeshesP "mesh") on its temporal support. - -The main properties of a field are : - -- name -- spatial support which is a \ref MEDCouplingMeshesP "mesh" -- a \ref MEDCouplingSpatialDisc "spatial discretization" -- a description of intrinsic nature of the values of field (see \ref NatureOfField). This is important for conservative interpolation (see \ref TableNatureOfField). -- a temporal discretization that specifies, if it exists, the time interval on which the field is covering, and how. -- number of components - -This definition of field in MEDCoupling allows an instance of field to -know at any point inside its spatial-temporal support the value. - -The class that incarnates the concept described above is : \ref ParaMEDMEM::MEDCouplingFieldDouble. - -Some of most important implemented methods are : - -- \ref ParaMEDMEM::MEDCouplingFieldDouble::getNumberOfComponents "getNumberOfComponents" -- \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOn "getValueOn" -- \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc "applyFunc" -- \ref ParaMEDMEM::MEDCouplingFieldDouble::addFields "cross instances operations" - -\section MEDCouplingSpatialDisc Spatial discretization concept - -This is the concept that makes the link, independantly from temporal -discretization, between the field and its spatial support(\ref MEDCouplingMeshesP "mesh"). This -concept allows the field to make a check and interpretation of an -array of values given a spatial support (\ref MEDCouplingMeshesP "mesh"). - -The abstract class that incarnates the concept is : \ref ParaMEDMEM::MEDCouplingFieldDiscretization. - -The most important pure virtual methods are : - -- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getNumberOfTuples "getnumberOfTuples" -- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOn "getValueOn" -- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField "getMeasureField" - -\section MEDCouplingTemporalDisc Temporal discretization concept - -This information allows, independantly from spatial discretization, to -associate a time interval, if it exists, on which the field will be -defined. This concept is able to give the value at any time of -the definition interval (if any). - -The abstract class \ref ParaMEDMEM::MEDCouplingTimeDiscretization -incarnates this described concept. - -This classes and its subclasses are responsible in storing the arrays -of the aggregating field. - -The most important methods are : - -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setTime "setTime" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getTime "getTime" -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArray "getArray" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setArray "setArray" -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArraysForTime "getArraysForTime" -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getValueForTime "getValueForTime" */ @@ -375,11 +264,16 @@ The most important methods are : \section MEDCouplingArrayIntro Introduction -This page will try to describe data arrays in MEDCoupling. Presently, -in MEDCoupling it exists two types of arrays : +One of the most basic concept mainly used all over MEDCoupling is +MEDCoupling array. + +This concept is used all over +\ref medcoupling "MEDCoupling", \ref paramedmem "ParaMEDMEM", \ref medloader "MEDLoader" modules so it should be correctly +handled to play well with \ref MEDCouplingMeshesPage "Meshes" and \ref MEDCouplingFieldsPage "Fields". -- double precision array incarnated by ParaMEDMEM::DataArrayDouble class. -- signed integer (32 bits) array incarnated by ParaMEDMEM::DataArrayInt class. +There are for the moment two types of arrays : + - double precision float (64 bits) array incarnated by ParaMEDMEM::DataArrayDouble class. + - signed integer (32 bits) array incarnated by ParaMEDMEM::DataArrayInt class. \section MEDCouplingArrayBasics Basics concepts @@ -606,3 +500,114 @@ sourceField->setNature(ConservativeVolumic); \endcode */ + +/*! + \page MEDCouplingUMeshPage Unstructured meshes in MEDCoupling + +An unstructured mesh in \ref medcoupling MEDCoupling is defined by : + + - a point clouds where the explicit coordinates of each point must be specified (inherited from \ref MEDCouplingPointSetPage "MEDCouplingPointSet class"). + - nodal connectivity that specifies for each cell, the points in the previous point clouds that constitutes the cell. + +As unstructured mesh is dynamically defined enough, this class is also used by MEDCoupling to instanciate degenerated meshes as : + +- points cloud only meshes. This type of mesh will have mesh dimension 0. +- abstract meshes containing only one cell that covers a potentially + infinite space. This abstract mesh is used as support of fields + containing only one integrated value. This is typically used to + represent fields used by system code. This type of mesh will have + mesh dimension equal to -1. + +The norm used for cells connectivity of different types, is the same as specified in MED file except +that connectivities are in represented in \b C \b format and \b not \b in \b FORTRAN \b format ! + +The class that incarnates the described concept is : ParaMEDMEM::MEDCouplingUMesh. +\n This class inherits from ParaMEDMEM::MEDCouplingPointSet abstract class. +\n So \ref MEDCouplingUMeshPage "MEDCouplingUMesh" inherits from all \ref MEDCouplingPointSetPage "point set features". + +\section MEDCouplingUMeshStdBuild Standard building of an unstructured mesh from scratch + +The described method here is called standard, because no special knowledge of underneath nodal connectivity is needed here. +This method of building unstructured mesh is easiest but not the most CPU/memory efficient one. + +All of exemples given here make the assumption that the \c ParaMEDMEM namespace is visible ( by calling for example \c using \c namespace \c ParaMEDMEM; ). + +Here we will create a mesh with spacedim==3 and meshdim==2. \b mesh contains 5 cells (with geometric type INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4) +and 9 nodes. + +You can notice that it is possible to mix cell types as long as the dimension of cell is exactly equal to meshDim to respect \ref MEDCouplingMeshes "this rule". + +\subpage medcouplingcppexamplesUmeshStdBuild1 "Here the C++ implementation." + +\subpage medcouplingpyexamplesUmeshStdBuild1 "Here the Python implementation." + +\section MEDCouplingUMeshAdvBuild Advanced building of an unstructured mesh from scratch + +Here we are going to build the mesh in a more advanced manner. This method expects that the user knows the storage format underlying ParaMEDMEM::MEDCouplingUMesh. + +The same mesh than \ref MEDCouplingUMeshStdBuild "in the standard section above" is going to be implemented using advanced method. + +\subpage medcouplingcppexamplesUmeshAdvBuild1 "Here the C++ implementation." + +\subpage medcouplingpyexamplesUmeshAdvBuild1 "Here the Python implementation." + +*/ + +/*! + \page MEDCouplingPointSetPage Point set meshes in MEDCoupling + +This is a \b non \b instanciable class that implements many algorithm working only on a set of points without any connectivity aspect. +The presence of this class is only for factorization reasons. + +The class that incarnates this concept in \ref medcoupling "MEDCoupling" is : \ref ParaMEDMEM::MEDCouplingPointSet. +Instanciable class ParaMEDMEM::MEDCouplingUMesh inherits from ParaMEDMEM::MEDCouplingPointSet. + +Some of most important implemented methods by \ref ParaMEDMEM::MEDCouplingPointSet "MEDCouplingPointSet" class are : + +- \ref ParaMEDMEM::MEDCouplingPointSet::getSpaceDimension "getSpaceDimension" +- \ref ParaMEDMEM::MEDCouplingPointSet::getNumberOfNodes "getNumberOfNodes" +- \ref ParaMEDMEM::MEDCouplingPointSet::rotate "rotate" +- \ref ParaMEDMEM::MEDCouplingPointSet::translate "translate" +- \ref ParaMEDMEM::MEDCouplingPointSet::scale "scale" +- \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes "findCommonNodes" +- \ref ParaMEDMEM::MEDCouplingPointSet::renumberNodes "renumberNodes" +- \ref ParaMEDMEM::MEDCouplingPointSet::getBoundingBox "getBoundingBox" +*/ + +/*! + \page MEDCouplingCMeshPage Cartesian meshes in MEDCoupling + +A cartesian mesh is a mesh that represents structured mesh whose nodes are arranged along axes of trihedron. To instanciate an object of this +type, only n arrays are needed. In this type of mesh space dimension \b and mesh dimension are equals and the value is n. +The n arrays will have only one component and the values contained in these arrays will be ascendantly sorted. + +The class that incarnates the described concept is : ParaMEDMEM::MEDCouplingCMesh. + +*/ + +/*! + \page MEDCouplingExtrudedPage 3D Extruded meshes in MEDCoupling + +An extruded mesh is a mesh also called 2.5 D. It a convolution of 2D +unstructured mesh with 1D unstructured mesh. The problem is that this +type of mesh is not managed by any file format that's why to build an +instance of this mesh you need 3D unstructured mesh and a 2D +unstructured mesh lying on the same coordinates. The advantage of this +structure is that the interpolation time is optimized. + +The class that incarnates this concept in MEDCoupling is : \ref ParaMEDMEM::MEDCouplingExtrudedMesh. +*/ + +/*! + \page MEDCouplingFieldTemplatesPage Field templates in MEDCoupling + +This concept appears in ICOCO API. +field template is the adequate datastructure to perform costly interpolation matrix computation as \ref RemapperClasses "Remapper class" does. +So, a field template can be seen as field without double values. The double values are only used for light matrix vector multiplication. + +Concretely a field template is a pair containing : + +- a \ref MEDCouplingMeshesPage "mesh" +- a spatial discretization (on cells, on nodes, on gauss points (including localizations, reference elements), ) + +*/ \ No newline at end of file diff --git a/doc/doxygen/medcouplingexamples.doxy b/doc/doxygen/medcouplingexamples.doxy index 777ecf822..65a0b3bf2 100644 --- a/doc/doxygen/medcouplingexamples.doxy +++ b/doc/doxygen/medcouplingexamples.doxy @@ -39,3 +39,53 @@ submesh of \b mesh1 containing cells whoses ids are in \b part2. So here the num method does not match the size of the input array (here \b part2). */ + +/*! +\page medcouplingcppexamplesUmeshStdBuild1

Example of standard build of an unstructured mesh from scratch in C++

+ +Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell. +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1 + +Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2 + +Gives an upper bound of the number of cells to be inserted into the unstructured mesh. +\n Then enter nodal connectivity of all cells, cell per cell using ParaMEDMEM::MEDCouplingUMesh::insertNextCell method. +\n When the nodal connectivity cell per cell has been finished, call ParaMEDMEM::MEDCouplingUMesh::finishInsertingCells method in order to restore \b mesh instance. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3 + +At this level the connectivity part of the mesh \b mesh as been defined. Now let's set the coordinates using array \b coords defined above. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4 + +At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5 + +*/ + +/*! +\page medcouplingcppexamplesUmeshAdvBuild1

Example of advanced build of an unstructured mesh from scratch in C++

+ +Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell. +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_1 + +Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2 + +Then enter nodal connectivity at once. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3 + +At this level the connectivity part of the mesh \b mesh as been defined. Now let's set the coordinates using array \b coords defined above. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4 + +At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter. + +\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5 + +*/ diff --git a/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx b/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx index 032beb403..228a012b3 100644 --- a/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx @@ -92,8 +92,77 @@ void CppExampleFieldDoubleBuildSubPart1() return; } +void CppSnippetUMeshStdBuild1() +{ + //! [CppSnippetUMeshStdBuild1_1] + double coords[27]={-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., + 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0. }; + int nodalConnPerCell[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4}; + //! [CppSnippetUMeshStdBuild1_1] + //! [CppSnippetUMeshStdBuild1_2] + ParaMEDMEM::MEDCouplingUMesh *mesh=ParaMEDMEM::MEDCouplingUMesh::New("My2DMesh",2); + //! [CppSnippetUMeshStdBuild1_2] + //! [CppSnippetUMeshStdBuild1_3] + mesh->allocateCells(5);//You can put more than 5 if you want but not less. + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,nodalConnPerCell); + mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,nodalConnPerCell+4); + mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,nodalConnPerCell+7); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,nodalConnPerCell+10); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,nodalConnPerCell+14); + mesh->finishInsertingCells(); + //! [CppSnippetUMeshStdBuild1_3] + //! [CppSnippetUMeshStdBuild1_4] + ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New(); + myCoords->alloc(9,3);//here myCoords are declared to have 3 components, mesh will deduce that its spaceDim==3. + std::copy(coords,coords+27,myCoords->getPointer()); + mesh->setCoords(myCoords);//myCorrds contains 9 tuples, that is to say mesh contains 9 nodes. + myCoords->decrRef(); + //! [CppSnippetUMeshStdBuild1_4] + mesh->checkCoherency(); + //! [CppSnippetUMeshStdBuild1_5] + mesh->decrRef(); + //! [CppSnippetUMeshStdBuild1_5] +} + +void CppSnippetUMeshAdvBuild1() +{ + //! [CppSnippetUMeshAdvBuild1_1] + double coords[27]={-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., + 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0. }; + int nodalConnPerCell[23]={4,0,3,4,1, 3,1,4,2, 3,4,5,2, 4,6,7,4,3, 4,7,8,5,4}; + int nodalConnPerCellIndex[6]={0,5,9,13,18,23}; + //! [CppSnippetUMeshAdvBuild1_1] + //! [CppSnippetUMeshAdvBuild1_2] + ParaMEDMEM::MEDCouplingUMesh *mesh=ParaMEDMEM::MEDCouplingUMesh::New("My2DMesh",2); + //! [CppSnippetUMeshAdvBuild1_2] + //! [CppSnippetUMeshAdvBuild1_3] + ParaMEDMEM::DataArrayInt *nodalConn=ParaMEDMEM::DataArrayInt::New(); + nodalConn->alloc(23,1); + std::copy(nodalConnPerCell,nodalConnPerCell+23,nodalConn->getPointer()); + ParaMEDMEM::DataArrayInt *nodalConnI=ParaMEDMEM::DataArrayInt::New(); + nodalConnI->alloc(6,1); + std::copy(nodalConnPerCellIndex,nodalConnPerCellIndex+6,nodalConnI->getPointer()); + mesh->setConnectivity(nodalConn,nodalConnI,true); + nodalConn->decrRef();// nodalConn DataArrayInt instance is owned by mesh after call to setConnectivity method. No more need here -> decrRef() + nodalConnI->decrRef();// nodalConnI DataArrayInt instance is owned by mesh after call to setConnectivity method. No more need here -> decrRef() + //! [CppSnippetUMeshAdvBuild1_3] + //! [CppSnippetUMeshAdvBuild1_4] + ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New(); + myCoords->alloc(9,3);//here myCoords are declared to have 3 components, mesh will deduce that its spaceDim==3. + std::copy(coords,coords+27,myCoords->getPointer()); + mesh->setCoords(myCoords);//myCorrds contains 9 tuples, that is to say mesh contains 9 nodes. + myCoords->decrRef(); + //! [CppSnippetUMeshAdvBuild1_4] + mesh->checkCoherency(); + //! [CppSnippetUMeshAdvBuild1_5] + mesh->decrRef(); + //! [CppSnippetUMeshAdvBuild1_5] +} + int main(int argc, char *argv[]) { CppExampleFieldDoubleBuildSubPart1(); + CppSnippetUMeshStdBuild1(); + CppSnippetUMeshAdvBuild1(); return 0; } diff --git a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py index b127750ac..eac187a30 100644 --- a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py @@ -135,6 +135,55 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.failUnlessEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13]) self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues())) pass + + def testExampleUMeshStdBuild1(self): + coords=[-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., + 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0. ] + nodalConnPerCell=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4] +# ! [PySnippetUMeshStdBuild1_1] +# ! [PySnippetUMeshStdBuild1_2] + mesh=MEDCouplingUMesh.New("My2DMesh",2) +# ! [PySnippetUMeshStdBuild1_2] +# ! [PySnippetUMeshStdBuild1_3] + mesh.allocateCells(5)#You can put more than 5 if you want but not less. + mesh.insertNextCell(NORM_QUAD4,nodalConnPerCell[:4]) + mesh.insertNextCell(NORM_TRI3,nodalConnPerCell[4:7]) + mesh.insertNextCell(NORM_TRI3,nodalConnPerCell[7:10]) + mesh.insertNextCell(NORM_QUAD4,nodalConnPerCell[10:14]) + mesh.insertNextCell(NORM_QUAD4,nodalConnPerCell[14:]) + mesh.finishInsertingCells() +# ! [PySnippetUMeshStdBuild1_3] +# ! [PySnippetUMeshStdBuild1_4] + myCoords=DataArrayDouble.New(coords,9,3)#here myCoords are declared to have 3 components, mesh will deduce that its spaceDim==3. + mesh.setCoords(myCoords)#myCorrds contains 9 tuples, that is to say mesh contains 9 nodes. +# ! [PySnippetUMeshStdBuild1_4] +# ! [PySnippetUMeshStdBuild1_5] +# ! [PySnippetUMeshStdBuild1_5] + mesh.checkCoherency() + pass + + def testExampleUMeshAdvBuild1(self): + coords=[-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., + 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0. ] + nodalConnPerCell=[4,0,3,4,1, 3,1,4,2, 3,4,5,2, 4,6,7,4,3, 4,7,8,5,4] + nodalConnPerCellIndex=[0,5,9,13,18,23] +# ! [PySnippetUMeshAdvBuild1_1] +# ! [PySnippetUMeshAdvBuild1_2] + mesh=MEDCouplingUMesh.New("My2DMesh",2) +# ! [PySnippetUMeshAdvBuild1_2] +# ! [PySnippetUMeshAdvBuild1_3] + nodalConn=DataArrayInt.New(nodalConnPerCell,23,1) + nodalConnI=DataArrayInt.New(nodalConnPerCellIndex,6,1) + mesh.setConnectivity(nodalConn,nodalConnI,True) +# ! [PySnippetUMeshAdvBuild1_3] +# ! [PySnippetUMeshAdvBuild1_4] + myCoords=DataArrayDouble.New(coords,9,3)#here myCoords are declared to have 3 components, mesh will deduce that its spaceDim==3. + mesh.setCoords(myCoords)#myCorrds contains 9 tuples, that is to say mesh contains 9 nodes. +# ! [PySnippetUMeshAdvBuild1_4] +# ! [PySnippetUMeshAdvBuild1_5] +# ! [PySnippetUMeshAdvBuild1_5] + mesh.checkCoherency() + pass pass unittest.main() -- 2.39.2