| 1 |
/* |
| 2 |
* (C) Copyright 2013 ECMWF. |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 7 |
* granted to it by virtue of its status as an intergovernmental organisation |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#include "atlas/mesh/ElementType.h" |
| 12 |
#include "elementtypes/Line.h" |
| 13 |
#include "elementtypes/Triangle.h" |
| 14 |
#include "elementtypes/Quadrilateral.h" |
| 15 |
#include "elementtypes/Pentagon.h" |
| 16 |
#include "atlas/runtime/Exception.h" |
| 17 |
#include "atlas/util/CoordinateEnums.h" |
| 18 |
|
| 19 |
namespace atlas { |
| 20 |
namespace mesh { |
| 21 |
|
| 22 |
//------------------------------------------------------------------------------ |
| 23 |
|
| 24 |
ElementType* ElementType::create( const std::string& name ) |
| 25 |
{ |
| 26 |
// currently naive implementation. This has to be replaced |
| 27 |
// with self-registration and factory mechanism |
| 28 |
if( name == "Triangle" ) { |
| 29 |
return new elementtypes::Triangle(); |
| 30 |
} else if( name == "Quadrilateral") { |
| 31 |
return new elementtypes::Quadrilateral(); |
| 32 |
} else if( name == "Line" ) { |
| 33 |
return new elementtypes::Line(); |
| 34 |
} else if( name == "Pentagon") { |
| 35 |
return new elementtypes::Pentagon(); |
| 36 |
} else { |
| 37 |
throw_NotImplemented("Element type ["+name+"] does not exist", Here()); |
| 38 |
} |
| 39 |
return nullptr; |
| 40 |
} |
| 41 |
|
| 42 |
ElementType::ElementType() = default; |
| 43 |
ElementType::~ElementType() = default; |
| 44 |
|
| 45 |
//----------------------------------------------------------------------------- |
| 46 |
|
| 47 |
extern "C" { |
| 48 |
void atlas__mesh__ElementType__delete(ElementType* This) { |
| 49 |
delete This; |
| 50 |
} |
| 51 |
|
| 52 |
ElementType* atlas__mesh__ElementType__create(const char* name) |
| 53 |
{ |
| 54 |
return ElementType::create( std::string(name) ); |
| 55 |
} |
| 56 |
|
| 57 |
const char* atlas__mesh__ElementType__name(const ElementType* This) { |
| 58 |
ATLAS_ASSERT(This); |
| 59 |
return This->name().c_str(); |
| 60 |
} |
| 61 |
|
| 62 |
idx_t atlas__mesh__ElementType__nb_nodes(const ElementType* This) { |
| 63 |
ATLAS_ASSERT(This); |
| 64 |
return This->nb_nodes(); |
| 65 |
} |
| 66 |
|
| 67 |
idx_t atlas__mesh__ElementType__nb_edges(const ElementType* This) { |
| 68 |
ATLAS_ASSERT(This); |
| 69 |
return This->nb_edges(); |
| 70 |
} |
| 71 |
|
| 72 |
int atlas__mesh__ElementType__parametric(const ElementType* This) { |
| 73 |
ATLAS_ASSERT(This); |
| 74 |
return This->parametric(); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
} // namespace mesh |
| 79 |
} // namespace atlas |