├── README.zh.md ├── src └── simpla │ ├── mesh │ ├── mesh.md │ ├── EBMesh.cpp │ ├── CMakeLists.txt │ ├── StructuredMesh.cpp │ └── StructuredMesh.h │ ├── engine │ ├── engine.md │ ├── CMakeLists.txt │ ├── Engine.h │ ├── backend │ │ ├── CMakeLists.txt │ │ └── SAMRAITimeIntegrator.h │ ├── TimeIntegrator.h │ ├── Patch.h │ ├── MeshBlock.h │ └── EBDomain.h │ ├── numeric │ ├── CMakeLists.txt │ ├── numeric.md │ ├── compound_distribution.h │ ├── normal_distribution_icdf.h │ ├── inverse_function.h │ ├── icdf_distribution.h │ ├── Integration.h │ ├── cholesky.h │ ├── half_split.h │ ├── ksp_cg.h │ └── simplex_distribution.h │ ├── physics │ ├── physics.md │ ├── particle │ │ ├── ParticleData.cpp │ │ ├── ParticleSort.cpp │ │ ├── ParticleData.h │ │ └── pre_define │ │ │ └── BorisParticle.h │ ├── CMakeLists.txt │ └── PhysicalQuantity.h │ ├── predefine │ ├── predefine.md │ ├── CMakeLists.txt │ ├── physics │ │ ├── PredefineDomains.h │ │ └── Maxwell.h │ ├── engine │ │ ├── SimpleTimeIntegrator.h │ │ └── SimpleTimeIntegrator.cpp │ └── device │ │ ├── ExtraSource.h │ │ └── ICRFAntenna.h │ ├── utilities │ ├── utilities.md │ ├── Logo.h │ ├── host_define.h │ ├── Multimethods.h │ ├── CMakeLists.txt │ ├── SingletonHolder.h │ ├── SingletonHandle.h │ ├── ParsingURI.cpp │ ├── SPDefines.h │ ├── Constants.h │ ├── Logo.cpp │ ├── ParsingURI.h │ └── ObjectHead.h │ ├── geometry │ ├── geometry.zh.md │ ├── gBody.cpp │ ├── Wire.cpp │ ├── BoundedSurface.cpp │ ├── gCurve.cpp │ ├── gSurface.cpp │ ├── Shell.cpp │ ├── gConic.cpp │ ├── gBox.cpp │ ├── Line.cpp │ ├── gLine.cpp │ ├── gTorus.cpp │ ├── gCircle.cpp │ ├── gCone.cpp │ ├── gPlane.cpp │ ├── gHyperbola.cpp │ ├── gParabola.cpp │ ├── Point.cpp │ ├── gWedge.cpp │ ├── gEllipse.cpp │ ├── gCylinder.cpp │ ├── gSphere.cpp │ ├── CMakeLists.txt │ ├── gConic.h │ ├── BoundedSurface.h │ ├── Point.h │ ├── Line.h │ ├── gBody.h │ ├── GeoEntity.cpp │ ├── Wire.h │ ├── Shell.h │ ├── Rectangle.h │ ├── gPlane.h │ ├── gLine.h │ ├── backend │ │ └── CMakeLists.txt │ ├── gBox.h │ ├── Cylinder.cpp │ ├── gPolygon.h │ ├── Rectangle.cpp │ ├── Sphere.cpp │ ├── gParabola.h │ ├── Solid.cpp │ ├── Cylinder.h │ ├── Sphere.h │ ├── Solid.h │ ├── Edge.cpp │ ├── Edge.h │ ├── Face.cpp │ ├── gHyperbola.h │ ├── gWedge.h │ ├── Face.h │ ├── Circle.cpp │ ├── Circle.h │ ├── gCurve.h │ ├── csCartesian.cpp │ ├── gSurface.h │ ├── gCircle.h │ ├── gCylinder.h │ ├── gSphere.h │ ├── gCone.h │ ├── gSweeping.h │ ├── gEllipse.h │ ├── gTorus.h │ ├── Box.cpp │ ├── CutCell.h │ ├── IntersectionCurveSurface.cpp │ ├── gSweeping.cpp │ ├── Sweeping.h │ ├── Box.h │ ├── gBoundedCurve.h │ ├── IntersectionCurveSurface.h │ └── GeoAlgorithm.cpp │ ├── data │ ├── data.md │ ├── DataBlock.cpp │ ├── CMakeLists.txt │ ├── DataPointCollection.h │ ├── data.puml │ ├── backend │ │ ├── DataBaseMDS.cpp │ │ ├── CMakeLists.txt │ │ └── DataEntryMemory.h │ ├── Serializable.cpp │ ├── Creatable.h │ ├── DataTraits.h │ ├── DataUtilities.cpp │ ├── DataFunction.h │ └── Data.h │ ├── scheme │ └── CMakeLists.txt │ ├── algebra │ ├── Array.cpp │ ├── CMakeLists.txt │ ├── SFC.h │ ├── sfc │ │ └── hilbert_sfc.h │ ├── Algebra.h │ └── EntityId.cpp │ ├── application │ ├── CMakeLists.txt │ ├── SPInit.h │ └── SPInit.cpp │ ├── parallel │ ├── CMakeLists.txt │ ├── Parallel.h │ ├── ParallelTbb.h │ ├── DistributedCounter.h │ ├── MPIComm.h │ └── MPIDataType.h │ └── CMakeLists.txt ├── scripts ├── PreProcess │ ├── __init__.py │ └── input_geqdsk.py ├── configure │ ├── test.py │ ├── disp_relation.md │ ├── mesh.xmf │ └── simpla.xmf ├── gfile │ └── g038300.03900.h5 ├── geqdsk.py ├── PostProcesse │ ├── pv_prog_source.py │ ├── particle.xdmf │ └── particle_time_scripts.py ├── draw_gridlines.py └── animation.py ├── CMake ├── hdf5-config.cmake ├── OpenCASCADEConfigVersion.cmake ├── HYPREConfig.cmake ├── OpenCASCADEConfig.cmake ├── FindSilo.cmake ├── SAMRAIConfig.cmake ├── utils.cmake ├── FindNumPy.cmake ├── FindPython.cmake ├── FindXdmf.cmake └── FindSAMRAI.cmake.disable ├── ChangeLog ├── test ├── utilities │ ├── CMakeLists.txt │ ├── log_test.cpp │ └── memory_pool_test.cpp ├── particle │ ├── CMakeLists.txt │ └── Particle_test.cpp ├── geometry │ └── CMakeLists.txt ├── data │ ├── DataType_test.cpp │ ├── test.lua │ ├── Configurable_dummy.cpp │ ├── CMakeLists.txt │ ├── SPObject_test.cpp │ └── XDMF_dummy.cpp ├── parallel │ ├── CMakeLists.txt │ ├── mpi_string_dummy.cpp │ └── MPIUpdater_test.cpp ├── Modeling │ ├── CMakeLists.txt │ └── modeling.cpp ├── engine │ ├── CMakeLists.txt │ ├── Attribute_test.cpp │ ├── Attribute_dummy.cpp │ └── policies_test.cpp ├── CMakeLists.txt └── algebra │ ├── field_basic_algebra_test.cpp │ ├── CMakeLists.txt │ └── array_dummy.cpp ├── docs ├── Design │ ├── class-diagram.dia │ └── worker-sequence-diagram.dia ├── INSTALL.md ├── UserGuide.md ├── configure_file_example │ ├── EMTokamak.xml │ └── EMTokamak.json ├── CMakeLists.txt ├── latex_header.tex ├── GeneralConventions.md └── DevGuide.md ├── .clang-format ├── example ├── CMakeLists.txt ├── EmbeddedBoundary │ └── CMakeLists.txt ├── MultiDomain │ └── CMakeLists.txt ├── SimpleMaxwell │ ├── CMakeLists.txt │ └── SimpleMaxwell.cpp └── tokamak │ └── CMakeLists.txt ├── external_project ├── SAMRAI │ ├── SAMRAIConfigVersion.cmake.in │ └── SAMRAIConfig.cmake.in ├── xdmf │ ├── XDMFConfigVersion.cmake │ ├── XML2ConfigVersion.cmake │ ├── XML2Config.cmake │ └── XDMFConfig.cmake └── IMAS │ └── INSTALL.md ├── .travis.yml ├── .gitignore ├── local_conf.cmake ├── README.md └── LICENSE /README.zh.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/mesh/mesh.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/engine/engine.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/PreProcess/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/numeric/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/numeric/numeric.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/physics/physics.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/predefine/predefine.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/utilities/utilities.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/simpla/geometry/geometry.zh.md: -------------------------------------------------------------------------------- 1 | 几何 2 | ========== 3 | -------------------------------------------------------------------------------- /CMake/hdf5-config.cmake: -------------------------------------------------------------------------------- 1 | set(HDF5_INCLUDE_DIRS /usr/include/openmpi-x86_64/) 2 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2013-10-24 salmon 2 | 3 | * src/particle/Particle.h: -------------------------------------------------------------------------------- /src/simpla/data/data.md: -------------------------------------------------------------------------------- 1 | Unified Data Model 2 | ========================================== -------------------------------------------------------------------------------- /src/simpla/geometry/gBody.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /src/simpla/scheme/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB FVM_SRC *.cpp *.h ) 2 | #add_library(FVM ${FVM_SRC}) -------------------------------------------------------------------------------- /src/simpla/geometry/Wire.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "Wire.h" 6 | -------------------------------------------------------------------------------- /test/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | #set_target_properties(array_dummy PROPERTIES COMPILE_FLAGS " -xcuda") 3 | -------------------------------------------------------------------------------- /docs/Design/class-diagram.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simpla-fusion/SimPla/HEAD/docs/Design/class-diagram.dia -------------------------------------------------------------------------------- /scripts/configure/test.py: -------------------------------------------------------------------------------- 1 | import SimPla 2 | ctx=SimPla.Context() 3 | 4 | a=ctx.getField("B0",2) 5 | print(a.shape) -------------------------------------------------------------------------------- /scripts/gfile/g038300.03900.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simpla-fusion/SimPla/HEAD/scripts/gfile/g038300.03900.h5 -------------------------------------------------------------------------------- /src/simpla/mesh/EBMesh.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-7-18. 3 | // 4 | 5 | #include "EBDomain.h" 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/INSTALL.md: -------------------------------------------------------------------------------- 1 | Install {#install} 2 | ========================================== 3 | 4 | @todo INSTALL doc 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/simpla/algebra/Array.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-18. 3 | // 4 | #include "Array.h" 5 | namespace simpla {} -------------------------------------------------------------------------------- /src/simpla/geometry/BoundedSurface.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-1. 3 | // 4 | 5 | #include "BoundedSurface.h" 6 | -------------------------------------------------------------------------------- /docs/UserGuide.md: -------------------------------------------------------------------------------- 1 | User Guide {#user_guide} 2 | ======================================================== 3 | @todo User Guide doc 4 | -------------------------------------------------------------------------------- /src/simpla/physics/particle/ParticleData.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-11. 3 | // 4 | 5 | #include "ParticleData.h" 6 | -------------------------------------------------------------------------------- /docs/Design/worker-sequence-diagram.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simpla-fusion/SimPla/HEAD/docs/Design/worker-sequence-diagram.dia -------------------------------------------------------------------------------- /scripts/configure/disp_relation.md: -------------------------------------------------------------------------------- 1 | Dispersion Relation {#disp_relation} 2 | ============================================ 3 | \ingroup UseCase -------------------------------------------------------------------------------- /src/simpla/physics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB physics_SRC *.cpp *.h ) 2 | add_library(physics ${physics_SRC} ) 3 | target_link_libraries(physics utilities ) 4 | -------------------------------------------------------------------------------- /src/simpla/application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB main_SRC *.cpp *.h ) 2 | add_library(SimPlaMain ${main_SRC}) 3 | TARGET_LINK_LIBRARIES(SimPlaMain ${SIMPLA_LIBRARIES}) 4 | SET(SIMPLA_MAIN SimPlaMain) -------------------------------------------------------------------------------- /test/particle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | simpla_test(Particle_test Particle_test.cpp) 2 | target_link_libraries(Particle_test data 3 | utilities algebra data parallel mesh engine particle 4 | 5 | ) -------------------------------------------------------------------------------- /src/simpla/geometry/gCurve.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-20. 3 | // 4 | 5 | #include "gCurve.h" 6 | namespace simpla { 7 | namespace geometry {} // namespace geometry { 8 | } // namespace simpla { 9 | -------------------------------------------------------------------------------- /src/simpla/geometry/gSurface.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-20. 3 | // 4 | #include "gSurface.h" 5 | namespace simpla { 6 | namespace geometry { 7 | } // namespace geometry { 8 | } // namespace simpla { 9 | -------------------------------------------------------------------------------- /src/simpla/data/DataBlock.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-15. 3 | // 4 | #include "DataBlock.h" 5 | namespace simpla { 6 | namespace data { 7 | 8 | 9 | 10 | } // namespace data 11 | } // namespace simpla -------------------------------------------------------------------------------- /src/simpla/algebra/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB_RECURSE algebra_SRC *.cpp *.h ) 2 | add_library(algebra ${algebra_SRC}) 3 | #target_link_libraries(physics ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${LUA_LIBRARIES} ${TBB_LIBRARIES}) 4 | 5 | -------------------------------------------------------------------------------- /src/simpla/data/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(backend) 2 | 3 | FILE(GLOB data_SRC *.cpp *.h ) 4 | add_library(data ${data_SRC}) 5 | target_link_libraries(data 6 | data_backend 7 | parallel utilities ) 8 | -------------------------------------------------------------------------------- /src/simpla/geometry/Shell.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-6. 3 | // 4 | 5 | #include "Shell.h" 6 | #include "GeoEntity.h" 7 | namespace simpla { 8 | namespace geometry {} // namespace geometry{ 9 | } // namespace simpla{ -------------------------------------------------------------------------------- /src/simpla/geometry/gConic.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "gConic.h" 6 | 7 | namespace simpla { 8 | namespace geometry {} // namespace geometry { 9 | } // namespace simpla { 10 | -------------------------------------------------------------------------------- /src/simpla/algebra/SFC.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-6-24. 3 | // 4 | 5 | #ifndef SIMPLA_SFC_H 6 | #define SIMPLA_SFC_H 7 | 8 | #include "sfc/hilbert_sfc.h" 9 | #include "sfc/z_sfc.h" 10 | #endif // SIMPLA_SFC_H 11 | -------------------------------------------------------------------------------- /src/simpla/geometry/gBox.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "gBox.h" 6 | namespace simpla { 7 | namespace geometry { 8 | SP_GEO_ENTITY_REGISTER(gBox) 9 | } // namespace geometry { 10 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/Line.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "Line.h" 6 | namespace simpla { 7 | namespace geometry { 8 | SP_GEO_OBJECT_REGISTER(Line) 9 | 10 | } // namespace geometry { 11 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/gLine.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "gLine.h" 6 | 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gLine) 10 | } // namespace geometry { 11 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/gTorus.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-24. 3 | // 4 | 5 | #include "gTorus.h" 6 | namespace simpla { 7 | namespace geometry { 8 | SP_GEO_ENTITY_REGISTER(gTorus) 9 | } // namespace geometry { 10 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/gCircle.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "gCircle.h" 6 | 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gCircle) 10 | } // namespace geometry { 11 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/gCone.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "gCone.h" 6 | 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gCone) 10 | } // namespace geometry { 11 | } // namespace simpla { 12 | -------------------------------------------------------------------------------- /src/simpla/geometry/gPlane.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-20. 3 | // 4 | 5 | #include "gPlane.h" 6 | namespace simpla { 7 | namespace geometry { 8 | SP_GEO_ENTITY_REGISTER(gPlane) 9 | } // namespace geometry { 10 | } // namespace simpla { 11 | -------------------------------------------------------------------------------- /src/simpla/application/SPInit.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-4. 3 | // 4 | 5 | #ifndef SIMPLA_SPINIT_H 6 | #define SIMPLA_SPINIT_H 7 | namespace simpla { 8 | int Initialize(int argc, char **argv); 9 | int Finalize(); 10 | } 11 | #endif // SIMPLA_SPINIT_H 12 | -------------------------------------------------------------------------------- /src/simpla/engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB engine_SRC *.cpp *.h ../scheme/FVM.h) 2 | add_library(engine ${engine_SRC}) 3 | target_link_libraries(engine data parallel) 4 | target_include_directories(engine BEFORE PRIVATE ${MPI_C_INCLUDE_PATH}) 5 | add_subdirectory(backend) -------------------------------------------------------------------------------- /src/simpla/geometry/gHyperbola.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "gHyperbola.h" 6 | 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gHyperbola) 10 | } // namespace geometry { 11 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/gParabola.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "gParabola.h" 6 | 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gParabola) 10 | } // namespace geometry { 11 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/Point.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-30. 3 | // 4 | 5 | #include "Point.h" 6 | #include "Box.h" 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_OBJECT_REGISTER(Point) 10 | 11 | } // namespace geometry 12 | } // namespace simpla -------------------------------------------------------------------------------- /src/simpla/algebra/sfc/hilbert_sfc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-6-24. 3 | // 4 | 5 | #ifndef SIMPLA_HILBERT_SFC_H 6 | #define SIMPLA_HILBERT_SFC_H 7 | namespace simpla { 8 | 9 | template 10 | struct hilbert_sfc {}; 11 | } 12 | #endif // SIMPLA_HILBERT_SFC_H 13 | -------------------------------------------------------------------------------- /test/geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | simpla_test(GeoObject_test GeoObject_test.cpp ../../src/simpla/geometry/GeoObject.cpp) 3 | target_link_libraries(GeoObject_test 4 | -Wl,--whole-archive 5 | data data_backend 6 | -Wl,--no-whole-archive 7 | 8 | ) 9 | # 10 | -------------------------------------------------------------------------------- /src/simpla/geometry/gWedge.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-7. 3 | // 4 | 5 | #include "gWedge.h" 6 | #include 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gWedge) 10 | 11 | } // namespace geometry 12 | } // namespace simpla -------------------------------------------------------------------------------- /scripts/geqdsk.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class GEQDSK: 4 | 5 | 6 | 7 | def read_geqdsk(filename): 8 | return res; 9 | 10 | 11 | def write_geqdsk(filename): 12 | return res; 13 | 14 | if __name__ == '__main__': 15 | read_geqdsk(f); 16 | write_geqdsk(f); 17 | pass -------------------------------------------------------------------------------- /src/simpla/engine/Engine.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-3-19. 3 | // 4 | 5 | #ifndef SIMPLA_ENGINE_ALL_H 6 | #define SIMPLA_ENGINE_ALL_H 7 | 8 | #include "Atlas.h" 9 | #include "Attribute.h" 10 | #include "Domain.h" 11 | #include "Scenario.h" 12 | 13 | #endif // SIMPLA_ENGINE_ALL_H 14 | -------------------------------------------------------------------------------- /src/simpla/geometry/gEllipse.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | #include "gEllipse.h" 5 | 6 | namespace simpla { 7 | namespace geometry { 8 | SP_GEO_ENTITY_REGISTER(gEllipseDisk) 9 | SP_GEO_ENTITY_REGISTER(gEllipse) 10 | 11 | } // namespace geometry { 12 | } // namespace simpla { -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | IndentWidth: 4 3 | --- 4 | Language: Cpp 5 | # Force pointers to the value_type_info for C++. 6 | PointerAlignment: Left 7 | ColumnLimit: 120 8 | AllowShortBlocksOnASingleLine: true 9 | AllowShortLoopsOnASingleLine: true 10 | AllowAllParametersOfDeclarationOnNextLine: true -------------------------------------------------------------------------------- /src/simpla/data/DataPointCollection.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-16. 3 | // 4 | 5 | #ifndef SIMPLA_DATAPOINTCOLLECTION_H 6 | #define SIMPLA_DATAPOINTCOLLECTION_H 7 | namespace simpla { 8 | namespace data { 9 | class DataPointCollection {}; 10 | } 11 | } 12 | #endif // SIMPLA_DATAPOINTCOLLECTION_H 13 | -------------------------------------------------------------------------------- /src/simpla/geometry/gCylinder.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-7-22. 3 | // 4 | 5 | #include "gCylinder.h" 6 | 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gCylinder) 10 | SP_GEO_ENTITY_REGISTER(gCylindricalSurface) 11 | } // namespace geometry { 12 | } // namespace simpla { 13 | -------------------------------------------------------------------------------- /src/simpla/geometry/gSphere.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-23. 3 | // 4 | 5 | #include "gSphere.h" 6 | 7 | namespace simpla { 8 | namespace geometry { 9 | SP_GEO_ENTITY_REGISTER(gSphere) 10 | SP_GEO_ENTITY_REGISTER(gSphereSurface) 11 | 12 | } // namespace geometry { 13 | } // namespace simpla { 14 | -------------------------------------------------------------------------------- /src/simpla/data/data.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | class DataEntry{ 3 | DataTable attributes 4 | DataEntry sub[] 5 | } 6 | 7 | class DataTable{ 8 | map m_values_ 9 | } 10 | class DataEntity{ 11 | } 12 | DataEntry *-- DataTable 13 | DataTable *-- DataEntity 14 | DataEntry *-- DataEntry 15 | @enduml -------------------------------------------------------------------------------- /src/simpla/geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB geometry_SRC *.cpp *.h) 2 | add_library(geometry ${geometry_SRC}) 3 | add_subdirectory(backend) 4 | 5 | TARGET_LINK_LIBRARIES(geometry utilities data geometry_backend) 6 | 7 | #FILE(GLOB geometry_SRC ./*.cpp) 8 | #add_library(geometry ${geometry_SRC} Cube.cpp CoordinateSystem.cpp) 9 | -------------------------------------------------------------------------------- /test/data/DataType_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-1-13. 3 | // 4 | 5 | #include (); 10 | std::cout << dtype.name() << std::endl; 11 | } 12 | -------------------------------------------------------------------------------- /src/simpla/parallel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #FILE(GLOB parallel_SRC./*.cpp) 2 | 3 | 4 | SET(parallel_SRC MPIComm.h MPIComm.cpp Parallel.cpp MPIUpdater.cpp MPIUpdater.h) 5 | add_library(parallel ${parallel_SRC}) 6 | target_link_libraries(parallel ${MPI_C_LIBRARIES}) 7 | target_include_directories(parallel BEFORE PRIVATE ${MPI_C_INCLUDE_PATH}) 8 | -------------------------------------------------------------------------------- /src/simpla/geometry/gConic.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_GCONIC_H 6 | #define SIMPLA_GCONIC_H 7 | #include "gCurve.h" 8 | #include "gSurface.h" 9 | namespace simpla { 10 | namespace geometry { 11 | 12 | } // namespace geometry{ 13 | } // namespace simpla 14 | #endif // SIMPLA_GCONIC_H 15 | -------------------------------------------------------------------------------- /src/simpla/physics/particle/ParticleSort.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-10. 3 | // 4 | #include "simpla/SIMPLA_config.h" 5 | namespace simpla { 6 | 7 | void ParticleUpdateTag(size_type num, id_type* tag, Real** r) {} 8 | void ParticleSort(size_type num, int num_of_attr, id_type const* tag_in, id_type* tag_out, Real** in, Real** out) {} 9 | } -------------------------------------------------------------------------------- /src/simpla/algebra/Algebra.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 16-12-22. 3 | // 4 | 5 | #ifndef SIMPLA_ALGEBRA_H_ 6 | #define SIMPLA_ALGEBRA_H_ 7 | 8 | #include "simpla/SIMPLA_config.h" 9 | 10 | #include 11 | #include "Array.h" 12 | #include "Calculus.h" 13 | #include "nTuple.ext.h" 14 | #include "nTuple.h" 15 | 16 | #endif // SIMPLA_ALGEBRA_H_ 17 | -------------------------------------------------------------------------------- /test/parallel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_EXECUTABLE(MPIUpdater_test MPIUpdater_test.cpp) 2 | target_link_libraries(MPIUpdater_test 3 | -Wl,--whole-archive 4 | data utilities data_backend parallel 5 | -Wl,--no-whole-archive 6 | ) 7 | ADD_EXECUTABLE(mpi_string_dummy mpi_string_dummy.cpp) 8 | target_link_libraries(mpi_string_dummy parallel utilities) 9 | -------------------------------------------------------------------------------- /src/simpla/predefine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #ADD_SUBDIRECTORY(case) 2 | #ADD_SUBDIRECTORY(field_solver) 3 | #ADD_SUBDIRECTORY(contexts) 4 | #ADD_SUBDIRECTORY(fokker_planck) 5 | 6 | FILE(GLOB_RECURSE predefine_SRC *.cpp *.h ) 7 | add_library(predefine ${predefine_SRC} ) 8 | target_include_directories(predefine BEFORE PRIVATE ${OCE_INCLUDE_DIRS}) 9 | target_link_libraries(predefine ${OCE_LIBRARIES} ) -------------------------------------------------------------------------------- /src/simpla/geometry/BoundedSurface.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-1. 3 | // 4 | 5 | #ifndef SIMPLA_BOUNDEDSURFACE_H 6 | #define SIMPLA_BOUNDEDSURFACE_H 7 | 8 | #include "gSurface.h" 9 | namespace simpla { 10 | namespace geometry { 11 | class BoundedSurface : public gSurface {}; 12 | } // namespace geometry 13 | } // namespace simpla 14 | 15 | #endif // SIMPLA_BOUNDEDSURFACE_H 16 | -------------------------------------------------------------------------------- /src/simpla/geometry/Point.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-30. 3 | // 4 | 5 | #ifndef SIMPLA_POINT_H 6 | #define SIMPLA_POINT_H 7 | #include "GeoObject.h" 8 | namespace simpla { 9 | namespace geometry { 10 | struct Point : public GeoObject { 11 | SP_GEO_OBJECT_HEAD(GeoObject, Point); 12 | }; 13 | } // namespace geometry 14 | } // namespace simpla 15 | #endif // SIMPLA_POINT_H 16 | -------------------------------------------------------------------------------- /src/simpla/geometry/Line.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_LINE_H 6 | #define SIMPLA_LINE_H 7 | #include 8 | #include "Edge.h" 9 | #include "GeoObject.h" 10 | namespace simpla { 11 | namespace geometry { 12 | struct Line : public Edge { 13 | SP_GEO_OBJECT_HEAD(Edge, Line) 14 | }; 15 | } // namespace geometry{ 16 | } // namespace simpla{ 17 | #endif // SIMPLA_LINE_H 18 | -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ADD_SUBDIRECTORY(SimpleMaxwell) 3 | ADD_SUBDIRECTORY(MultiDomain) 4 | ADD_SUBDIRECTORY(EmbeddedBoundary) 5 | 6 | ADD_SUBDIRECTORY(tokamak) 7 | #ADD_SUBDIRECTORY(em) 8 | #ADD_SUBDIRECTORY(multi_block) 9 | #ADD_SUBDIRECTORY(mhd_test) 10 | #IF(CUDA_FOUND) 11 | #ADD_SUBDIRECTORY(cuda_test) 12 | #ENDIF(CUDA_FOUND) 13 | 14 | #add_subdirectory(Modeling) 15 | #add_subdirectory(step2meshkit) 16 | #add_subdirectory(em_tokamak) -------------------------------------------------------------------------------- /CMake/OpenCASCADEConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "6.9.1") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else () 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif () 11 | endif () -------------------------------------------------------------------------------- /src/simpla/geometry/gBody.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-18. 3 | // 4 | 5 | #ifndef SIMPLA_BODY_H 6 | #define SIMPLA_BODY_H 7 | 8 | #include 9 | #include "GeoEntity.h" 10 | 11 | namespace simpla { 12 | namespace geometry { 13 | 14 | struct gBody : public GeoEntity { 15 | SP_GEO_ENTITY_ABS_HEAD(GeoEntity, gBody) 16 | }; 17 | 18 | } // namespace geometry 19 | } // namespace simpla 20 | #endif // SIMPLA_BODY_H 21 | -------------------------------------------------------------------------------- /src/simpla/parallel/Parallel.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file parallel.h 3 | * 4 | * created on: 2014-3-27 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef PARALLEL_H_ 9 | #define PARALLEL_H_ 10 | 11 | #include 12 | namespace simpla { 13 | namespace parallel { 14 | void Initialize(int argc, char **argv); 15 | void Finalize(); 16 | std::string help_message(); 17 | } //{ namespace parallel 18 | } // namespace simpla 19 | 20 | #endif /* PARALLEL_H_ */ 21 | -------------------------------------------------------------------------------- /src/simpla/numeric/compound_distribution.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file compound_distribution.h 3 | * @author salmon 4 | * @date 2015-11-27. 5 | */ 6 | 7 | #ifndef SIMPLA_COMPOUND_DISTRIBUTION_H 8 | #define SIMPLA_COMPOUND_DISTRIBUTION_H 9 | 10 | namespace simpla 11 | { 12 | template 13 | struct compound_distribution 14 | { 15 | std::tuple...> value_type; 16 | 17 | }; 18 | } 19 | 20 | #endif //SIMPLA_COMPOUND_DISTRIBUTION_H 21 | -------------------------------------------------------------------------------- /external_project/SAMRAI/SAMRAIConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@SAMRAI_VERSION@") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() -------------------------------------------------------------------------------- /src/simpla/utilities/Logo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file simpla_lib.cpp.h 3 | * @author salmon 4 | * @date 2015-10-21. 5 | */ 6 | 7 | #ifndef SIMPLA_SIMPLA_LIB_CPP_H 8 | #define SIMPLA_SIMPLA_LIB_CPP_H 9 | 10 | #include 11 | 12 | namespace simpla 13 | { 14 | 15 | std::string ShowLogo(); 16 | std::string ShowVersion(); 17 | std::string ShowLogo(); 18 | 19 | void TheStart(int flag = 1); 20 | void TheEnd(int flag = 1); 21 | 22 | } 23 | #endif //SIMPLA_SIMPLA_LIB_CPP_H 24 | -------------------------------------------------------------------------------- /scripts/PostProcesse/pv_prog_source.py: -------------------------------------------------------------------------------- 1 | from vtk . numpy_interface import dataset_adapter as dsa 2 | from vtk . numpy_interface import algorithms as algs 3 | import h5py as h5 4 | f1=h5.File("/pkg/etc/clion/system/cmake/generated/2774870a/2774870a/Debug/example/em/tokamak0007.h5") 5 | x=f1["/record/0/H"][:]['p']['v'] 6 | coords=algs.make_vector(x[:,0],x[:,1],x[:,2]) 7 | pts=vtk.vtkPoints() 8 | pts.SetData(dsa.numpyTovtkDataArray ( coords , " Points ")) 9 | output.SetPoints(pts) 10 | -------------------------------------------------------------------------------- /src/simpla/utilities/host_define.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-6-23. 3 | // 4 | 5 | #ifndef SIMPLA_HOST_DEFINE_H 6 | #define SIMPLA_HOST_DEFINE_H 7 | 8 | #ifndef __CUDA__ 9 | #define __host__ 10 | #define __device__ 11 | #define __managed__ 12 | #else 13 | #include 14 | #include 15 | #include 16 | #endif 17 | #endif // SIMPLA_HOST_DEFINE_H 18 | -------------------------------------------------------------------------------- /test/Modeling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB modeling_SRC ./*.cpp 2 | ../../src/simpla/predefine/device/Tokamak.h 3 | ../../src/simpla/predefine/device/Tokamak.cpp 4 | ) 5 | ADD_EXECUTABLE(modeling ${modeling_SRC}) 6 | #SET_TARGET_PROPERTIES(tokamak PROPERTIES COMPILE_FLAGS " -xcuda ") 7 | 8 | TARGET_LINK_LIBRARIES(modeling 9 | -Wl,--whole-archive 10 | utilities geometry geometry_backend data data_backend 11 | -Wl,--no-whole-archive 12 | ) -------------------------------------------------------------------------------- /test/data/test.lua: -------------------------------------------------------------------------------- 1 | PI = 3.141592653589793 2 | Context = { 3 | c = 299792458, -- m/s 4 | qe = 1.60217656e-19, -- C 5 | me = 9.10938291e-31, --kg 6 | mp = 1.672621777e-27, --kg 7 | mp_me = 1836.15267245, -- 8 | KeV = 1.1604e7, -- K 9 | Tesla = 1.0, -- Tesla 10 | TWOPI = PI * 2, 11 | k_B = 1.3806488e-23, --Boltzmann_constant 12 | epsilon0 = 8.8542e-12, 13 | AAA = { c = "3", d = { c = "3", e = { 1, 3, 4, 5 } } }, 14 | CCC = { 1, 3, 4, 5 } 15 | } -------------------------------------------------------------------------------- /src/simpla/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE(${PROJECT_SOURCE_DIR}/CMake/utils.cmake) 2 | 3 | SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_LIST_DIR}) 4 | FOREACH (subdir ${SUBDIRS}) 5 | MESSAGE("Add sub directory: ${subdir}") 6 | ADD_SUBDIRECTORY(${subdir}) 7 | ENDFOREACH () 8 | 9 | 10 | 11 | #TARGET_LINK_LIBRARIES(SimPlaLib 12 | # netcdf ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${TBB_LIBRARIES} 13 | # utilities geometry parallel data mesh engine geometry physics third_part 14 | # ) 15 | 16 | -------------------------------------------------------------------------------- /external_project/xdmf/XDMFConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "3") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | 13 | MESSAGE("-- XDMF version: ${PACKAGE_VERSION}") -------------------------------------------------------------------------------- /src/simpla/physics/PhysicalQuantity.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 16-10-5. 3 | // 4 | 5 | #ifndef SIMPLA_PHYSICALQUANTITY_H 6 | #define SIMPLA_PHYSICALQUANTITY_H 7 | 8 | #include "simpla/_config.h" 9 | #include 10 | 11 | namespace simpla { namespace physic 12 | { 13 | /** 14 | * 15 | */ 16 | class PhysicalQuantity 17 | { 18 | std::string name; 19 | size_type m_id_; 20 | Real m_si_[6]; 21 | size_type m_num_of_dims_; 22 | 23 | }; 24 | }} 25 | #endif //SIMPLA_PHYSICALQUANTITY_H 26 | -------------------------------------------------------------------------------- /external_project/xdmf/XML2ConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "2.9.4") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | 13 | MESSAGE("-- XML2 version: ${PACKAGE_VERSION}") -------------------------------------------------------------------------------- /test/engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | simpla_test(Attribute_test Attribute_test.cpp) 2 | target_link_libraries(Attribute_test 3 | -Wl,--whole-archive 4 | algebra engine geometry data utilities data_backend 5 | -Wl,--no-whole-archive 6 | 7 | ) 8 | 9 | ADD_EXECUTABLE(Attribute_dummy Attribute_dummy.cpp) 10 | target_link_libraries(Attribute_dummy 11 | -Wl,--whole-archive 12 | algebra engine geometry data utilities data_backend 13 | -Wl,--no-whole-archive 14 | 15 | ) -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c++ 2 | sudo: required 3 | dist: trusty 4 | compiler: 5 | - gcc 6 | before_script: 7 | - sudo apt-Serialize install cmake nvidia-cuda_test-dev libtbb2 libtbb-dev libboost-all-dev openmpi-bin libopenmpi-dev libhdf5-openmpi-dev liblua5.2-dev libgtest-dev 8 | - test -n $CC && unset CC 9 | - test -n $CXX && unset CXX 10 | - mkdir build 11 | - cd build 12 | - cmake .. 13 | script: 14 | - make demo_em 15 | branches: 16 | only: 17 | - master 18 | -------------------------------------------------------------------------------- /src/simpla/geometry/GeoEntity.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-6. 3 | // 4 | 5 | #include "GeoEntity.h" 6 | #include "Edge.h" 7 | #include "Face.h" 8 | #include "Solid.h" 9 | namespace simpla { 10 | namespace geometry { 11 | GeoEntity::GeoEntity() = default; 12 | GeoEntity::GeoEntity(GeoEntity const &other) : data::Configurable(other) {} 13 | 14 | GeoEntity::~GeoEntity() = default; 15 | std::string GeoEntity::FancyTypeName() const { return "GeoEntity"; } 16 | 17 | } // namespace geometry{ 18 | } // namespace simpla{ -------------------------------------------------------------------------------- /src/simpla/geometry/Wire.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_WIRE_H 6 | #define SIMPLA_WIRE_H 7 | #include 8 | #include "Edge.h" 9 | namespace simpla { 10 | namespace geometry { 11 | struct Wire : public GeoObject { 12 | SP_GEO_OBJECT_ABS_HEAD(GeoObject, Wire) 13 | virtual size_type size() const = 0; 14 | virtual std::shared_ptr GetEdge(size_type n) = 0; 15 | }; 16 | } // namespace geometry{ 17 | } // namespace simpla{ 18 | #endif // SIMPLA_WIRE_H 19 | -------------------------------------------------------------------------------- /test/engine/Attribute_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-2-15. 3 | // 4 | 5 | #include "simpla/engine/Attribute.h" 6 | #include 7 | #include "simpla/data/Data.h" 8 | using namespace simpla; 9 | using namespace simpla::data; 10 | 11 | TEST(TestAttribute, GUID) { 12 | engine::AttributeT f; 13 | engine::AttributeT g; 14 | 15 | EXPECT_EQ(f.GetRank(), 0); 16 | EXPECT_EQ(g.GetRank(), 1); 17 | 18 | std::cout << f[0] << std::endl; 19 | std::cout << g[0] << std::endl; 20 | } 21 | -------------------------------------------------------------------------------- /external_project/xdmf/XML2Config.cmake: -------------------------------------------------------------------------------- 1 | SET(XML2_FOUND TRUE) 2 | SET(XML2_INCLUDE_DIRS /usr/include/libxml2/ ) 3 | SET(XML2_LIBRARY_DIRS /usr/lib/x86_64-linux-gnu/) 4 | SET(XML2_LIBRARIES @XML2_LIBRARIES_DEP@ ) 5 | 6 | SET(XML2_LIBRARIES_LIST xml2) 7 | 8 | FOREACH (LIB_ ${XML2_LIBRARIES_LIST}) 9 | find_library(${LIB_}_FILE NAMES ${LIB_} PATHS ${XML2_LIBRARY_DIRS}) 10 | IF (NOT ${LIB_}_FILE-NOTFOUND) 11 | LIST(APPEND XML2_LIBRARIES ${${LIB_}_FILE}) 12 | ENDIF (NOT ${LIB_}_FILE-NOTFOUND) 13 | ENDFOREACH (LIB_ ${XML2_LIBRARIES_LIST}) -------------------------------------------------------------------------------- /scripts/draw_gridlines.py: -------------------------------------------------------------------------------- 1 | fig,ax=subplots() 2 | 3 | ax.set_xticks(arange(0.5,20.5,1),minor=True) 4 | ax.set_xticks(arange(0,20,1),minor=False) 5 | ax.xaxis.grid(True,which='minor',color='r',linestyle='--') 6 | ax.xaxis.grid(True,which='major',color='b',linestyle='-') 7 | 8 | ax.set_yticks(arange(0.5,20.5,1),minor=True) 9 | ax.set_yticks(arange(0,20,1),minor=False) 10 | ax.yaxis.grid(True,which='major',color='b',linestyle='-') 11 | ax.yaxis.grid(True,which='minor',color='r',linestyle='--') 12 | 13 | plot(f1["/p0"][:][:,0],f1["/p0"][:][:,1]) 14 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES(/pkg/google_benchmark/current/include) 2 | LINK_DIRECTORIES(/pkg/google_benchmark/current/lib) 3 | 4 | 5 | INCLUDE(${PROJECT_SOURCE_DIR}/CMake/utils.cmake) 6 | 7 | SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_LIST_DIR}) 8 | FOREACH (subdir ${SUBDIRS}) 9 | MESSAGE("Add sub directory: ${subdir}") 10 | ADD_SUBDIRECTORY(${subdir}) 11 | ENDFOREACH () 12 | 13 | 14 | #add_subdirectory(engine) 15 | #add_subdirectory(algebra) 16 | #add_subdirectory(geometry) 17 | #add_subdirectory(concept) 18 | #add_subdirectory(data) -------------------------------------------------------------------------------- /example/EmbeddedBoundary/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB EmbeddedBoundary_SRC ./*.cpp) 2 | ADD_EXECUTABLE(EmbeddedBoundary ${EmbeddedBoundary_SRC}) 3 | #SET_TARGET_PROPERTIES(tokamak PROPERTIES COMPILE_FLAGS " -xcuda ") 4 | TARGET_LINK_LIBRARIES(EmbeddedBoundary SimPlaMain 5 | ${HDF5_LIBRARIES} ${MPI_C_LIBRARIES} 6 | -Wl,--whole-archive 7 | utilities algebra parallel mesh engine geometry physics data data_backend 8 | predefine 9 | -Wl,--no-whole-archive 10 | ${OPENMP_LIBRARIES} ${CUDA_LIBRARIES} 11 | ) -------------------------------------------------------------------------------- /src/simpla/geometry/Shell.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-6. 3 | // 4 | 5 | #ifndef SIMPLA_SHELL_H 6 | #define SIMPLA_SHELL_H 7 | #include 8 | #include "Face.h" 9 | namespace simpla { 10 | namespace geometry { 11 | struct Shell : public GeoObject { 12 | SP_GEO_OBJECT_ABS_HEAD(GeoObject, Shell) 13 | virtual size_type size() const { return 0; }; 14 | virtual std::shared_ptr GetFace(size_type n) { return nullptr; }; 15 | }; 16 | } // namespace geometry{ 17 | } // namespace simpla{ 18 | #endif // SIMPLA_SHELL_H 19 | -------------------------------------------------------------------------------- /example/MultiDomain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB MultiDomain_SRC ./*.cpp) 2 | ADD_EXECUTABLE(MultiDomain ${MultiDomain_SRC}) 3 | #SET_TARGET_PROPERTIES(tokamak PROPERTIES COMPILE_FLAGS " -xcuda ") 4 | TARGET_LINK_LIBRARIES(MultiDomain SimPlaMain 5 | ${HDF5_LIBRARIES} ${MPI_C_LIBRARIES} 6 | -Wl,--whole-archive 7 | utilities algebra parallel mesh engine physics predefine 8 | geometry geometry_backend 9 | data data_backend 10 | -Wl,--no-whole-archive 11 | ${OPENMP_LIBRARIES} ${CUDA_LIBRARIES} 12 | ) 13 | -------------------------------------------------------------------------------- /example/SimpleMaxwell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB SimpleMaxwell_SRC ./*.cpp) 2 | ADD_EXECUTABLE(SimpleMaxwell ${SimpleMaxwell_SRC}) 3 | #SET_TARGET_PROPERTIES(tokamak PROPERTIES COMPILE_FLAGS " -xcuda ") 4 | TARGET_LINK_LIBRARIES(SimpleMaxwell SimPlaMain 5 | ${HDF5_LIBRARIES} ${MPI_C_LIBRARIES} 6 | -Wl,--whole-archive 7 | utilities algebra parallel mesh engine physics predefine 8 | geometry geometry_backend 9 | data data_backend 10 | -Wl,--no-whole-archive 11 | ${OPENMP_LIBRARIES} ${CUDA_LIBRARIES} 12 | ) 13 | -------------------------------------------------------------------------------- /src/simpla/geometry/Rectangle.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_RECTANGLE_H 6 | #define SIMPLA_RECTANGLE_H 7 | #include "Face.h" 8 | namespace simpla { 9 | namespace geometry { 10 | 11 | struct Rectangle : public Face { 12 | SP_GEO_OBJECT_HEAD(Face, Rectangle) 13 | explicit Rectangle(Axis const &axis, Real r0, Real r1, Real a0, Real a1); 14 | explicit Rectangle(Axis const &axis, std::tuple const &); 15 | }; 16 | } // namespace geometry{ 17 | } // namespace simpla{ 18 | #endif // SIMPLA_RECTANGLE_H 19 | -------------------------------------------------------------------------------- /src/simpla/geometry/gPlane.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-20. 3 | // 4 | 5 | #ifndef SIMPLA_GPLANE_H 6 | #define SIMPLA_GPLANE_H 7 | 8 | #include "gSurface.h" 9 | namespace simpla { 10 | namespace geometry { 11 | struct gPlane : public gSurface { 12 | SP_GEO_ENTITY_HEAD(gSurface, gPlane, Plane); 13 | virtual point2d_type xy(Real u, Real v) const { return point2d_type{u, v}; }; 14 | point_type xyz(Real u, Real v) const override { return point_type{u, v, 0}; }; 15 | }; 16 | 17 | } // namespace geometry 18 | } // namespace simpla 19 | #endif // SIMPLA_GPLANE_H 20 | -------------------------------------------------------------------------------- /scripts/PreProcess/input_geqdsk.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 2013-6-9 3 | 4 | @author: salmon 5 | ''' 6 | 7 | class GEQDSK(object): 8 | ''' 9 | G-EQDSK File 10 | ''' 11 | def read_from(self,f): 12 | fid=open(f) 13 | lines= fid.readlines() 14 | self.idnum=int(str[-3]) 15 | self.nw=int(str[-2]) 16 | self.nh=int(str[-1]) 17 | strs=fid.readline.split() 18 | return; 19 | def write_to(self,f): 20 | return; 21 | 22 | def __init__(selfparams): 23 | ''' 24 | Constructor 25 | ''' 26 | return; -------------------------------------------------------------------------------- /example/tokamak/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB tokamak_SRC ./*.cpp) 2 | ADD_EXECUTABLE(tokamak ${tokamak_SRC}) 3 | #SET_TARGET_PROPERTIES(tokamak PROPERTIES COMPILE_FLAGS " -xcuda ") 4 | MESSAGE(STATUS ${OPENMP_LIBRARIES} ) 5 | TARGET_LINK_LIBRARIES(tokamak SimPlaMain 6 | netcdf ${HDF5_LIBRARIES} ${MPI_C_LIBRARIES} ${TBB_LIBRARIES} 7 | -Wl,--whole-archive 8 | utilities algebra parallel mesh engine physics geometry geometry_backend data data_backend 9 | predefine 10 | -Wl,--no-whole-archive 11 | ${OPENMP_LIBRARIES} ${CUDA_LIBRARIES} 12 | ) 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.bak 3 | # Compiled GeoObject files 4 | *.slo 5 | *.lo 6 | *.o 7 | *.obj 8 | 9 | # Precompiled Headers 10 | *.gch 11 | *.pch 12 | 13 | # Compiled Dynamic libraries 14 | *.so 15 | *.dylib 16 | *.dll 17 | 18 | # Fortran module files 19 | *.mod 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | *.lib 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | 32 | # Directory 33 | build*/ 34 | #third_part 35 | .idea*/ 36 | .directory 37 | 38 | 39 | # misc 40 | .tags 41 | .cproject 42 | .project 43 | .settings/ 44 | external_project/*/src/ 45 | cmake-build-* 46 | -------------------------------------------------------------------------------- /src/simpla/geometry/gLine.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_GLINE_H 6 | #define SIMPLA_GLINE_H 7 | 8 | #include "gCurve.h" 9 | namespace simpla { 10 | namespace geometry { 11 | struct gLine : public gCurve { 12 | SP_GEO_ENTITY_HEAD(gCurve, gLine, Line) 13 | explicit gLine(vector_type const& direction) : m_Direction_(direction) {} 14 | SP_PROPERTY(vector_type, Direction) = {1, 0, 0}; 15 | point_type xyz(Real u) const override { return m_Direction_ * u; }; 16 | }; 17 | } // namespace geometry 18 | } // namespace simpla 19 | #endif // SIMPLA_GLINE_H 20 | -------------------------------------------------------------------------------- /src/simpla/engine/backend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF (CUDA_FOUND) 2 | SET(SAMRAI_DIR /pkg/SAMRAI/3.11.2/clang-4.0.0/lib/cmake/SAMRAI/) 3 | FIND_PACKAGE(SAMRAI REQUIRED) 4 | ENDIF (CUDA_FOUND) 5 | IF (SAMRAI_FOUND) 6 | MESSAGE("-- SAMRAI Version: " ${SAMRAI_VERSION}) 7 | ENDIF (SAMRAI_FOUND) 8 | 9 | FILE(GLOB third_part_SRC *.cpp *.h) 10 | add_library(third_part ${third_part_SRC}) 11 | TARGET_LINK_LIBRARIES(third_part ${SAMRAI_LIBRARIES}) 12 | TARGET_INCLUDE_DIRECTORIES(third_part BEFORE PRIVATE ${SAMRAI_INCLUDE_DIRS}) 13 | 14 | # SET_TARGET_PROPERTIES(third_part PROPERTIES COMPILE_FLAGS " -xcuda ") 15 | 16 | -------------------------------------------------------------------------------- /src/simpla/numeric/normal_distribution_icdf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file normal_distribution_icdf.h 3 | * 4 | * created on: 2013-10-23 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef NORMAL_DISTRIBUTION_ICDF_H_ 9 | #define NORMAL_DISTRIBUTION_ICDF_H_ 10 | 11 | #include "icdf_distribution.h" 12 | #include 13 | namespace simpla 14 | { 15 | /** @ingroup numeric */ 16 | class normal_distribution_icdf 17 | { 18 | 19 | public: 20 | private: 21 | normal_distribution_icdf(double mean, double stddev) 22 | { 23 | 24 | } 25 | 26 | }; 27 | 28 | } // namespace simpla 29 | 30 | #endif /* NORMAL_DISTRIBUTION_ICDF_H_ */ 31 | -------------------------------------------------------------------------------- /src/simpla/geometry/backend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | FIND_PACKAGE(OCE) 3 | IF (OCE_FOUND) 4 | MESSAGE("-- OCE VERSION: ${OCE_VERSION} INCLUDE: ${OCE_INCLUDE_DIRS}") 5 | LIST(APPEND geometry_backend_SRC GeoEngineOCE.cpp GeoEngineOCE.h ) 6 | LIST(APPEND geometry_backend_INCLUDE ${OCE_INCLUDE_DIRS}) 7 | LIST(APPEND geometry_backend_LIBRARIES ${OCE_LIBRARIES}) 8 | ENDIF (OCE_FOUND) 9 | add_library(geometry_backend ${geometry_backend_SRC}) 10 | target_include_directories(geometry_backend BEFORE PRIVATE ${geometry_backend_INCLUDE}) 11 | TARGET_LINK_LIBRARIES(geometry_backend utilities data ${geometry_backend_LIBRARIES}) -------------------------------------------------------------------------------- /src/simpla/geometry/gBox.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_GBOX_H 6 | #define SIMPLA_GBOX_H 7 | 8 | #include 9 | #include "gBody.h" 10 | namespace simpla { 11 | namespace geometry { 12 | 13 | struct gBox : public gBody { 14 | SP_GEO_ENTITY_HEAD(gBody, gBox, Box) 15 | explicit gBox(vector_type const &extents) : m_Extents_(extents) {} 16 | point_type xyz(Real u, Real v, Real w) const override { return point_type{u, v, w}; } 17 | SP_PROPERTY(vector_type, Extents); 18 | }; 19 | 20 | } // namespace geometry 21 | } // namespace simpla 22 | #endif // SIMPLA_GBOX_H 23 | -------------------------------------------------------------------------------- /src/simpla/numeric/inverse_function.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file inverse_function.h 3 | * 4 | * created on: 2013-12-2 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef INVERSE_FUNCTION_H_ 9 | #define INVERSE_FUNCTION_H_ 10 | #include 11 | namespace simpla 12 | { 13 | /**@ingroup numeric*/ 14 | template 15 | std::map Inverse(std::map const & xy) 16 | { 17 | std::map res; 18 | for (auto const &p : xy) 19 | { 20 | res.emplace(std::make_pair(p.second, p.first)); 21 | } 22 | 23 | return std::move(res); 24 | 25 | } 26 | 27 | } // namespace simpla 28 | 29 | #endif /* INVERSE_FUNCTION_H_ */ 30 | -------------------------------------------------------------------------------- /src/simpla/geometry/Cylinder.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "Cylinder.h" 6 | #include "Face.h" 7 | #include "Solid.h" 8 | #include "gCylinder.h" 9 | namespace simpla { 10 | namespace geometry { 11 | SP_GEO_OBJECT_REGISTER(Cylinder) 12 | SP_GEO_OBJECT_REGISTER(CylinderSurface) 13 | 14 | Cylinder::Cylinder(Axis const &axis, box_type const &b) : Solid(axis, gCylinder::New(), b) {} 15 | 16 | CylinderSurface::CylinderSurface(Axis const &axis, Real radius, std::tuple const &b) 17 | : Face(axis, gCylindricalSurface::New(radius), b) {} 18 | } // namespace geometry { 19 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/gPolygon.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file polygon.h 3 | * @author salmon 4 | * @date 2015-11-17. 5 | */ 6 | #ifndef SIMPLA_GPOLYGON_H 7 | #define SIMPLA_GPOLYGON_H 8 | 9 | #include 10 | #include 11 | #include "gBoundedCurve.h" 12 | namespace simpla { 13 | namespace geometry { 14 | 15 | struct gPolygon2D : public gBoundedCurve2D { 16 | SP_GEO_ENTITY_HEAD(gBoundedCurve2D, gPolygon2D, Polygon2D) 17 | }; 18 | 19 | struct gPolygon : public gBoundedCurve { 20 | SP_GEO_ENTITY_HEAD(gBoundedCurve, gPolygon, Polygon) 21 | }; 22 | } // namespace geometry 23 | } // namespace simpla 24 | #endif // SIMPLA_GPOLYGON_H 25 | -------------------------------------------------------------------------------- /src/simpla/utilities/Multimethods.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-18. 3 | // 4 | 5 | #ifndef SIMPLA_MULTIMETHODS_H 6 | #define SIMPLA_MULTIMETHODS_H 7 | 8 | #include 9 | namespace simpla { 10 | template 11 | struct VisitorT; 12 | struct Visitor { 13 | template 14 | std::shared_ptr> New(); 15 | }; 16 | 17 | template 18 | struct VisitorT { 19 | virtual void visit(V &) = 0; 20 | }; 21 | 22 | template 23 | struct MultiMethods { 24 | void accept(Visitor &visitor) { visitor.New()->visit(*this); } 25 | }; 26 | } // namespace simpla 27 | #endif // SIMPLA_MULTIMETHODS_H 28 | -------------------------------------------------------------------------------- /scripts/animation.py: -------------------------------------------------------------------------------- 1 | import matplotlib.animation as animation 2 | import h5py as H5 3 | 4 | 5 | 6 | f1=H5.File("data_dump/geqdsk0027.h5","r") 7 | 8 | r=linspace(1.2,2.8,128) 9 | q=linspace(0,6.28/4,128) 10 | q,r=meshgrid(q,r) 11 | 12 | fig=figure() 13 | 14 | def animate(iter): 15 | clf(); 16 | contour(r*sin(q),r*cos(q),f1["/Save/E1"][iter+1,:,:,2]) 17 | 18 | anim = animation.FuncAnimation(fig,animate ,frames=range(720),interval=20,blit=False,repeat=True) 19 | 20 | metadata = dict(title='Movie Test', artist='YuZhi', 21 | comment='LHW') 22 | 23 | writer =animation.FFMpegWriter(fps=30, metadata=metadata) 24 | 25 | anim.write("a.mp4",writer) 26 | -------------------------------------------------------------------------------- /src/simpla/geometry/Rectangle.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "Rectangle.h" 6 | #include "Edge.h" 7 | #include "Face.h" 8 | #include "Rectangle.h" 9 | #include "gPlane.h" 10 | 11 | namespace simpla { 12 | namespace geometry { 13 | SP_GEO_OBJECT_REGISTER(Rectangle) 14 | Rectangle::Rectangle(Axis const &axis, Real r0, Real r1, Real a0, Real a1) 15 | : Face(axis, gPlane::New(), std::make_tuple(point2d_type{r0, a0}, point2d_type{r1, a1})) {} 16 | Rectangle::Rectangle(Axis const &axis, std::tuple const &b) 17 | : Face(axis, gPlane::New(), b) {} 18 | } // namespace geometry { 19 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/Sphere.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "Sphere.h" 6 | #include "Face.h" 7 | #include "Solid.h" 8 | #include "gSphere.h" 9 | namespace simpla { 10 | namespace geometry { 11 | SP_GEO_OBJECT_REGISTER(Sphere) 12 | SP_GEO_OBJECT_REGISTER(SphereSurface) 13 | 14 | Sphere::Sphere(Axis const &axis, box_type const &range) : Solid(axis, simpla::geometry::gSphere::New(), range) {} 15 | 16 | SphereSurface::SphereSurface(Axis const &axis, Real radius, std::tuple const &b) 17 | : Face(axis, simpla::geometry::gSphereSurface::New(radius), b) {} 18 | } // namespace geometry { 19 | } // namespace simpla { -------------------------------------------------------------------------------- /src/simpla/geometry/gParabola.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-22. 3 | // 4 | 5 | #ifndef SIMPLA_GPARABOLA_H 6 | #define SIMPLA_GPARABOLA_H 7 | 8 | #include 9 | #include "gCone.h" 10 | 11 | namespace simpla { 12 | namespace geometry { 13 | 14 | struct gParabola : public gConic { 15 | SP_GEO_ENTITY_HEAD(gConic, gParabola, Parabola); 16 | explicit gParabola(Real focal) : m_Focal_(focal) {} 17 | SP_PROPERTY(Real, Focal); 18 | point2d_type xy(Real u) const override { return point2d_type{u * u / (4. * m_Focal_), u}; }; 19 | }; 20 | 21 | } // namespace geometry{ 22 | } // namespace simpla{ 23 | #endif // SIMPLA_GPARABOLA_H 24 | -------------------------------------------------------------------------------- /src/simpla/predefine/physics/PredefineDomains.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-26. 3 | // 4 | 5 | #ifndef SIMPLA_PREDEFINEDOMAINS_H 6 | #define SIMPLA_PREDEFINEDOMAINS_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | namespace simpla { 14 | typedef engine::Domain CartesianFVM; 15 | typedef engine::Domain CylindricalFVM; 16 | } // namespace simpla { 17 | 18 | #endif // SIMPLA_PREDEFINEDOMAINS_H 19 | -------------------------------------------------------------------------------- /src/simpla/geometry/Solid.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-18. 3 | // 4 | 5 | #include "Solid.h" 6 | #include "gBody.h" 7 | namespace simpla { 8 | namespace geometry { 9 | Solid::Solid(Axis const &axis, std::shared_ptr const &body, box_type const &b) 10 | : GeoObjectHandle(axis, body, b) {}; 11 | void Solid::SetBody(std::shared_ptr const &s) { 12 | GeoObjectHandle::SetBasisGeometry(std::dynamic_pointer_cast(s)); 13 | } 14 | std::shared_ptr Solid::GetBody() const { 15 | return std::dynamic_pointer_cast(GeoObjectHandle::GetBasisGeometry()); 16 | } 17 | 18 | } // namespace geometry 19 | } // namespace simpla -------------------------------------------------------------------------------- /src/simpla/predefine/engine/SimpleTimeIntegrator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-5. 3 | // 4 | 5 | #ifndef SIMPLA_SIMPLETIMEINTEGRATOR_H 6 | #define SIMPLA_SIMPLETIMEINTEGRATOR_H 7 | 8 | #include "simpla/engine/TimeIntegrator.h" 9 | namespace simpla { 10 | class SimpleTimeIntegrator : public engine::TimeIntegrator { 11 | SP_ENABLE_NEW_HEAD(engine::TimeIntegrator, SimpleTimeIntegrator); 12 | 13 | public: 14 | void DoSetUp() override; 15 | void DoUpdate() override; 16 | void DoTearDown() override; 17 | void Synchronize(int) override; 18 | void Advance(Real time_now, Real time_dt) override; 19 | }; 20 | } // namespace simpla 21 | #endif // SIMPLA_SIMPLETIMEINTEGRATOR_H 22 | -------------------------------------------------------------------------------- /src/simpla/geometry/Cylinder.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_CYLINDER_H 6 | #define SIMPLA_CYLINDER_H 7 | 8 | #include "Face.h" 9 | #include "Solid.h" 10 | namespace simpla { 11 | namespace geometry { 12 | 13 | struct Cylinder : public Solid { 14 | SP_GEO_OBJECT_HEAD(Solid, Cylinder) 15 | explicit Cylinder(Axis const &axis, box_type const &); 16 | }; 17 | struct CylinderSurface : public Face { 18 | SP_GEO_OBJECT_HEAD(Face, CylinderSurface) 19 | explicit CylinderSurface(Axis const &axis, Real radius, std::tuple const &b); 20 | }; 21 | 22 | } // namespace geometry { 23 | } // namespace simpla { 24 | #endif // SIMPLA_CYLINDER_H 25 | -------------------------------------------------------------------------------- /test/parallel/mpi_string_dummy.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-23. 3 | // 4 | 5 | #include 6 | #include 7 | #include 8 | #include "simpla/SIMPLA_config.h" 9 | using namespace simpla; 10 | int main(int argc, char** argv) { 11 | parallel::Initialize(argc, argv); 12 | std::cout << "[" << GLOBAL_COMM.rank() << "]" 13 | << parallel::gather_string("rank[" + std::to_string(GLOBAL_COMM.rank()) + "]", 2) << std::endl; 14 | 15 | std::cout << "[" << GLOBAL_COMM.rank() << "]" 16 | << parallel::gather_string("rank[" + std::to_string(GLOBAL_COMM.rank()) + "]", -1) << std::endl; 17 | parallel::Finalize(); 18 | } -------------------------------------------------------------------------------- /docs/configure_file_example/EMTokamak.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/simpla/geometry/Sphere.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_SPHERE_H 6 | #define SIMPLA_SPHERE_H 7 | #include "Face.h" 8 | #include "Solid.h" 9 | namespace simpla { 10 | namespace geometry { 11 | 12 | struct Sphere : public Solid { 13 | SP_GEO_OBJECT_HEAD(Solid, Sphere) 14 | protected: 15 | explicit Sphere(Axis const &axis, box_type const &range); 16 | }; 17 | struct SphereSurface : public Face { 18 | SP_GEO_OBJECT_HEAD(Face, SphereSurface) 19 | protected: 20 | explicit SphereSurface(Axis const &axis, Real radius, std::tuple const &b); 21 | }; 22 | 23 | } // namespace geometry { 24 | } // namespace simpla { 25 | #endif // SIMPLA_SPHERE_H 26 | -------------------------------------------------------------------------------- /src/simpla/mesh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | #IF (NOT MOAB_DIR) 3 | # SET(MOAB_DIR /pkg/sigma/1.2/lib) 4 | # SET(MeshKit_DIR /pkg/sigma/1.2/lib) 5 | #ENDIF (NOT MOAB_DIR) 6 | # 7 | #FIND_PACKAGE(MOAB REQUIRED) 8 | #FIND_PACKAGE(MeshKit REQUIRED) 9 | #IF (MOAB_FOUND) 10 | # MESSAGE(" -- MOAB Found: ${MOAB_LIBRARIES}; INCLUDE: ${MOAB_INCLUDE_DIRS}") 11 | #ENDIF (MOAB_FOUND) 12 | #IF (MeshKit_FOUND) 13 | # MESSAGE(" -- MeshKit Found: ${MESHKIT_LIBRARIES}; INCLUDE: ${MESHKIT_INCLUDE_DIRS}") 14 | #ENDIF (MeshKit_FOUND) 15 | # 16 | #INCLUDE_DIRECTORIES(${MOAB_INCLUDE_DIRS} ${MESHKIT_INCLUDE_DIRS}) 17 | 18 | 19 | FILE(GLOB mesh_SRC *.cpp *.h ) 20 | add_library(mesh ${mesh_SRC} ) 21 | 22 | TARGET_LINK_LIBRARIES(mesh utilities) 23 | 24 | -------------------------------------------------------------------------------- /CMake/HYPREConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SET(HYPRE_FOUND TRUE) 6 | SET(HYPRE_INCLUDE_DIRS /usr) 7 | 8 | SET(HYPRE_LIBRARIES 9 | HYPRE_FEI_fgmres 10 | HYPRE_DistributedMatrixPilutSolver 11 | HYPRE_sstruct_mv 12 | HYPRE_seq_mv 13 | HYPRE_krylov 14 | HYPRE_multivector 15 | HYPRE_ParaSails 16 | HYPRE_MatrixMatrix 17 | HYPRE_parcsr_mv 18 | HYPRE_utilities 19 | HYPRE_FEI 20 | HYPRE 21 | HYPRE_parcsr_block_mv 22 | HYPRE_struct_ls 23 | HYPRE_Euclid 24 | HYPRE_parcsr_ls 25 | HYPRE_DistributedMatrix 26 | HYPRE_mli 27 | HYPRE_sstruct_ls 28 | HYPRE_struct_mv 29 | HYPRE_IJ_mv 30 | ) -------------------------------------------------------------------------------- /external_project/xdmf/XDMFConfig.cmake: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(XML2) 2 | 3 | SET(XDMF_FOUND TRUE) 4 | SET(XDMF_DIR /usr) 5 | SET(XDMF_INCLUDE_DIRS ${XML2_INCLUDE_DIRS} ${XDMF_DIR}/include) 6 | SET(XDMF_LIBRARY_DIRS /usr/lib/x86_64-linux-gnu/xdmf/serial/) 7 | SET(XDMF_LIBRARIES ${XDMF_LIBRARIES}) 8 | 9 | SET(XDMF_LIBRARIES_LIST 10 | Xdmf 11 | XdmfCore 12 | XdmfUtils 13 | ) 14 | 15 | FOREACH (LIB_ ${XDMF_LIBRARIES_LIST}) 16 | find_library(${LIB_}_FILE NAMES ${LIB_} PATHS ${XDMF_LIBRARY_DIRS}) 17 | IF (NOT ${LIB_}_FILE-NOTFOUND) 18 | LIST(APPEND XDMF_LIBRARIES ${${LIB_}_FILE}) 19 | ENDIF (NOT ${LIB_}_FILE-NOTFOUND) 20 | ENDFOREACH (LIB_ ${XDMF_LIBRARIES_LIST}) 21 | 22 | MESSAGE("-- XDMF include: ${XDMF_INCLUDE_DIRS}") -------------------------------------------------------------------------------- /src/simpla/geometry/Solid.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-18. 3 | // 4 | 5 | #ifndef SIMPLA_SOLID_H 6 | #define SIMPLA_SOLID_H 7 | 8 | #include "GeoObject.h" 9 | namespace simpla { 10 | namespace geometry { 11 | struct gBody; 12 | struct GeoEntity; 13 | struct Solid : public GeoObjectHandle { 14 | SP_GEO_OBJECT_HEAD(GeoObjectHandle, Solid); 15 | 16 | protected: 17 | explicit Solid(Axis const &axis, std::shared_ptr const &body, 18 | box_type const &range = box_type{{0, 0, 0}, {1, 1, 1}}); 19 | 20 | public: 21 | void SetBody(std::shared_ptr const &s); 22 | std::shared_ptr GetBody() const; 23 | }; 24 | } // namespace geometry{ 25 | } // namespace simpla{ 26 | #endif // SIMPLA_SOLID_H 27 | -------------------------------------------------------------------------------- /src/simpla/geometry/Edge.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-17. 3 | // 4 | 5 | #include "Edge.h" 6 | #include "gCurve.h" 7 | 8 | namespace simpla { 9 | namespace geometry { 10 | 11 | Edge::Edge(Axis const &axis, std::shared_ptr const &curve, std::tuple const &b) 12 | : GeoObjectHandle(axis, curve, box_type{{std::get<0>(b), 0, 0}, {std::get<1>(b), 1, 1}}){}; 13 | 14 | void Edge::SetCurve(std::shared_ptr const &s) { 15 | GeoObjectHandle::SetBasisGeometry(std::dynamic_pointer_cast(s)); 16 | } 17 | std::shared_ptr Edge::GetCurve() const { 18 | return std::dynamic_pointer_cast(GeoObjectHandle::GetBasisGeometry()); 19 | } 20 | 21 | } // namespace geometry 22 | } // namespace simpla -------------------------------------------------------------------------------- /src/simpla/geometry/Edge.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-17. 3 | // 4 | 5 | #ifndef SIMPLA_EDGE_H 6 | #define SIMPLA_EDGE_H 7 | #include 8 | #include "GeoObject.h" 9 | 10 | namespace simpla { 11 | namespace geometry { 12 | struct gCurve; 13 | struct Edge : public GeoObjectHandle { 14 | SP_GEO_OBJECT_HEAD(GeoObjectHandle, Edge); 15 | 16 | protected: 17 | explicit Edge(Axis const &axis, std::shared_ptr const &curve, 18 | std::tuple const &range = {0, 1}); 19 | 20 | public: 21 | void SetCurve(std::shared_ptr const &s); 22 | std::shared_ptr GetCurve() const; 23 | }; 24 | } // namespace geometry{ 25 | } // namespace simpla{ 26 | 27 | #endif // SIMPLA_EDGE_H 28 | -------------------------------------------------------------------------------- /test/engine/Attribute_dummy.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-9. 3 | // 4 | 5 | #include 6 | #include "simpla/data/Data.h" 7 | #include "simpla/engine/Attribute.h" 8 | using namespace simpla; 9 | using namespace simpla::data; 10 | int main(int argc, char** argv) { 11 | engine::AttributeT f{nullptr, "F"_}; 12 | engine::AttributeT g{nullptr, "G"_}; 13 | 14 | std::cout << f.GetRank() << std::endl; 15 | std::cout << g.GetRank() << std::endl; 16 | 17 | engine::AttributeT h{nullptr, "H"_}; 18 | h = [&](int w, index_type x, index_type y, index_type z) { return 1.0; }; 19 | 20 | engine::AttributeT h3{nullptr, "H3"_}; 21 | h3 = [&](int w, index_type x, index_type y, index_type z) { return 1.0; }; 22 | } -------------------------------------------------------------------------------- /CMake/OpenCASCADEConfig.cmake: -------------------------------------------------------------------------------- 1 | # - Config file for the OpenCASCADE package 2 | # It defines the following variables 3 | # OpenCASCADE_INCLUDE_DIRS - include directories for OpenCASCADE 4 | # OpenCASCADE_LIBRARIES - libraries to link against 5 | # OpenCASCADE_EXECUTABLE - the bar executable 6 | 7 | # Compute paths 8 | set(OpenCASCADE_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}") 9 | set(OpenCASCADE_INCLUDE_DIRS "${OpenCASCADE_CMAKE_DIR}/../inc") 10 | 11 | # Our library dependencies (contains definitions for IMPORTED targets) 12 | if (NOT TARGET foo AND NOT OpenCASCADE_BINARY_DIR) 13 | include("${OpenCASCADE_CMAKE_DIR}/OpenCASCADETargets.cmake") 14 | endif () 15 | 16 | # These are IMPORTED targets created by OpenCASCADETargets.cmake 17 | set(OpenCASCADE_LIBRARIES foo) 18 | set(OpenCASCADE_EXECUTABLE bar) -------------------------------------------------------------------------------- /src/simpla/geometry/Face.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-14. 3 | // 4 | 5 | #include "Face.h" 6 | namespace simpla { 7 | namespace geometry { 8 | 9 | Face::Face(Axis const &axis, std::shared_ptr const &surface, 10 | std::tuple const &b) 11 | : GeoObjectHandle(axis, surface, 12 | box_type{{std::get<0>(b)[0], std::get<0>(b)[1], 0}, {std::get<1>(b)[0], std::get<1>(b)[1], 1}}){}; 13 | 14 | void Face::SetSurface(std::shared_ptr const &s) { GeoObjectHandle::SetBasisGeometry(s); } 15 | std::shared_ptr Face::GetSurface() const { 16 | return std::dynamic_pointer_cast(GeoObjectHandle::GetBasisGeometry()); 17 | } 18 | 19 | } // namespace geometry 20 | } // namespace simpla -------------------------------------------------------------------------------- /src/simpla/numeric/icdf_distribution.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file icdf_distribution.h 3 | * 4 | * created on: 2013-10-23 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef ICDF_DISTRIBUTION_H_ 9 | #define ICDF_DISTRIBUTION_H_ 10 | 11 | #include "Interpolation.h" 12 | #include "inverse_function.h" 13 | #include "Integration.h" 14 | namespace simpla 15 | { 16 | /** @ingroup numeric*/ 17 | 18 | template 19 | inline TIntepolation MakeICDF(std::map const &fun) 20 | { 21 | auto res = Inverse(Integrate(fun)); 22 | auto f = res.rbegin()->second; 23 | for (auto & p : res) 24 | { 25 | p.second /= f; 26 | } 27 | return std::move(TIntepolation(std::move(res))); 28 | } 29 | 30 | } 31 | // namespace simpla 32 | 33 | #endif /* ICDF_DISTRIBUTION_H_ */ 34 | -------------------------------------------------------------------------------- /src/simpla/geometry/gHyperbola.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-22. 3 | // 4 | 5 | #ifndef SIMPLA_GHYPERBOLA_H 6 | #define SIMPLA_GHYPERBOLA_H 7 | 8 | #include "gCone.h" 9 | namespace simpla { 10 | namespace geometry { 11 | 12 | struct gHyperbola : public gConic { 13 | SP_GEO_ENTITY_HEAD(gConic, gHyperbola, Hyperbola) 14 | gHyperbola(Real major_radius, Real minor_radius) : m_MajorRadius_(major_radius), m_MinorRadius_(minor_radius){}; 15 | SP_PROPERTY(Real, MajorRadius) = 1.0; 16 | SP_PROPERTY(Real, MinorRadius) = 0.5; 17 | 18 | point2d_type xy(Real alpha) const override { 19 | return point2d_type{m_MajorRadius_ * std::cosh((alpha)), m_MinorRadius_ * std::sinh((alpha))}; 20 | }; 21 | }; 22 | } // namespace geometry{ 23 | } // namespace simpla{ 24 | #endif // SIMPLA_GHYPERBOLA_H 25 | -------------------------------------------------------------------------------- /src/simpla/geometry/gWedge.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-7. 3 | // 4 | 5 | #ifndef SIMPLA_GWEDGE_H 6 | #define SIMPLA_GWEDGE_H 7 | 8 | #include 9 | #include 10 | #include "gBody.h" 11 | namespace simpla { 12 | namespace geometry { 13 | 14 | struct gWedge : public gBody { 15 | SP_GEO_ENTITY_HEAD(gBody, gWedge, Wedge) 16 | 17 | explicit gWedge(vector_type const &extents, Real ltx) : m_Extents_(extents), m_LTX_(ltx) {} 18 | 19 | point_type xyz(Real u, Real v, Real w) const override { 20 | UNIMPLEMENTED; 21 | return point_type{0, 0, 0}; 22 | } 23 | 24 | SP_PROPERTY(vector_type, Extents); 25 | SP_PROPERTY(Real, LTX); 26 | }; 27 | 28 | } // namespace geometry 29 | } // namespace simpla 30 | #endif // SIMPLA_GWEDGE_H 31 | -------------------------------------------------------------------------------- /src/simpla/geometry/Face.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-14. 3 | // 4 | 5 | #ifndef SIMPLA_FACE_H 6 | #define SIMPLA_FACE_H 7 | 8 | #include 9 | #include "GeoObject.h" 10 | #include "gSurface.h" 11 | namespace simpla { 12 | namespace geometry { 13 | struct Face : public GeoObjectHandle { 14 | SP_GEO_OBJECT_HEAD(GeoObjectHandle, Face); 15 | 16 | protected: 17 | explicit Face(Axis const &axis, std::shared_ptr const &surface, 18 | std::tuple const &range = {{0, 0}, {1, 1}}); 19 | 20 | public: 21 | void SetSurface(std::shared_ptr const &s); 22 | std::shared_ptr GetSurface() const; 23 | }; 24 | 25 | } // namespace geometry 26 | } // namespace simpla 27 | #endif // SIMPLA_FACE_H 28 | -------------------------------------------------------------------------------- /CMake/FindSilo.cmake: -------------------------------------------------------------------------------- 1 | #- Find Silo 2 | # INPUT: 3 | # SILO_DIR 4 | # This module will define the following variable: 5 | # OUTPUT: 6 | # SILO_INCLUDE_DIRS 7 | # SILO_LIBRARIES 8 | include(SelectLibraryConfigurations) 9 | include(FindPackageHandleStandardArgs) 10 | 11 | if(SILO_INCLUDE_DIR ) 12 | #DO NOTHING 13 | else() 14 | find_path(SILO_INCLUDE_DIR 15 | NAMES silo.h 16 | HINTS ${SILO_DIR}/include 17 | NO_DEFAULT_PATH 18 | ) 19 | find_library("SILO_LIBRARIES" 20 | NAME ${CMAKE_STATIC_LIBRARY_PREFIX}silo${CMAKE_STATIC_LIBRARY_SUFFIX} 21 | HINTS ${SILO_DIR}/lib 22 | NO_DEFAULT_PATH 23 | ) 24 | SET(SILO_FOUND true) 25 | endif() 26 | 27 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Silo DEFAULT_MSG SILO_INCLUDE_DIR ) 28 | -------------------------------------------------------------------------------- /local_conf.cmake: -------------------------------------------------------------------------------- 1 | SET(ARCH intel64) 2 | SET(COMPILER $ENV{PRG_ENV}) 3 | 4 | SET(SIMPLA_VERSION_MAJOR 0) 5 | SET(SIMPLA_VERSION_MINOR 0) 6 | SET(SIMPLA_VERSION_PATCHLEVEL 0) 7 | 8 | execute_process(COMMAND git describe --all --dirty --long 9 | OUTPUT_VARIABLE SIMPLA_VERSION_IDENTIFY 10 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 11 | OUTPUT_STRIP_TRAILING_WHITESPACE 12 | ) 13 | 14 | SET(AUTHOR " YU Zhi ") 15 | SET(COPYRIGHT "All rights reserved. (2017 )") 16 | 17 | SET(BUILD_TOOLS ON) 18 | 19 | SET(SP_REAL double) 20 | 21 | SET(SP_ARRAY_MAX_NDIMS 8) 22 | SET(SP_ARRAY_DEFAULT_ORDER SLOW_FIRST) # SLOW_FIRST , FAST_FIRST 23 | SET(SP_ARRAY_INITIALIZE_VALUE SP_SNaN) 24 | 25 | SET(SIMPLA_OUTPUT_SUFFIX SimPLA) 26 | SET(DOC_LANGUAGE Chinese) 27 | #SET(SAMRAI_DIR /pkg/SAMRAI/3.11.0-debug/) 28 | 29 | -------------------------------------------------------------------------------- /docs/configure_file_example/EMTokamak.json: -------------------------------------------------------------------------------- 1 | { 2 | "Scenario": { 3 | "Mesh": { 4 | "Chart": { 5 | "Type": "Cylindrical" 6 | }, 7 | "Box": { 8 | "lo": [ 9 | 0, 10 | 0, 11 | 0 12 | ], 13 | "hi": [ 14 | 1, 15 | 1, 16 | 1 17 | ], 18 | "Dimension": [ 19 | 32, 20 | 32, 21 | 32 22 | ] 23 | } 24 | }, 25 | "Domain": [ 26 | { 27 | "Type": "EMFluid", 28 | "Name": "Plasma", 29 | "Boundary":{} 30 | }, 31 | { 32 | "Type": "PIC", 33 | "Particle": [ 34 | { 35 | "Name": "H" 36 | }, 37 | { 38 | "Name": "ele" 39 | } 40 | ] 41 | } 42 | ] 43 | } 44 | } -------------------------------------------------------------------------------- /CMake/SAMRAIConfig.cmake: -------------------------------------------------------------------------------- 1 | SET(SAMRAI_FOUND TRUE) 2 | SET(SAMRAI_DIR /pkg/SAMRAI/3.11.0-debug-hdf5-1.10-openmpi-2.0.2) 3 | SET(SAMRAI_INCLUDE_DIRS ${SAMRAI_DIR}/include) 4 | SET(SAMRAI_LIBRARY_DIRS ${SAMRAI_DIR}/lib) 5 | 6 | SET(SAMRAI_LIBRARIES_ 7 | # SAMRAI_testlib 8 | appu 9 | algs 10 | solv 11 | geom 12 | mesh 13 | math 14 | pdat 15 | xfer 16 | hier 17 | tbox 18 | ) 19 | 20 | 21 | 22 | FOREACH (LIB_ ${SAMRAI_LIBRARIES_}) 23 | find_library(SAMRAI_${LIB_} NAMES SAMRAI_${LIB_} PATHS ${SAMRAI_LIBRARY_DIRS}) 24 | IF (NOT SAMRAI_${LIB_}_NOTFOUND) 25 | LIST(APPEND SAMRAI_LIBRARIES "${SAMRAI_${LIB_}}") 26 | ENDIF (NOT SAMRAI_${LIB_}_NOTFOUND) 27 | ENDFOREACH () 28 | 29 | LIST(APPEND SAMRAI_LIBRARIES gfortran ${MPI_LIBRARIES} ${HDF5_LIBRARIES}) 30 | -------------------------------------------------------------------------------- /src/simpla/physics/particle/ParticleData.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-11. 3 | // 4 | 5 | #ifndef SIMPLA_PARTICLEDATA_H 6 | #define SIMPLA_PARTICLEDATA_H 7 | 8 | #include "simpla/SIMPLA_config.h" 9 | 10 | #include 11 | 12 | namespace simpla { 13 | struct ParticleData : public data::DataEntity { 14 | SP_DEFINE_FANCY_TYPE_NAME(ParticleData, data::DataEntity); 15 | ParticleData(int DOF = 0, size_type NumberOfPIC = 100) : m_dof_(DOF), m_number_of_pic_(NumberOfPIC) {} 16 | ~ParticleData() override = default; 17 | 18 | size_type GetNumberOfPIC() const { return m_number_of_pic_; } 19 | void SetNumberOfPIC(size_type n) { m_number_of_pic_ = n; } 20 | 21 | private: 22 | int m_dof_ = 0; 23 | size_type m_number_of_pic_ = 100; 24 | }; 25 | } // namespace simpla 26 | 27 | #endif // SIMPLA_PARTICLEDATA_H 28 | -------------------------------------------------------------------------------- /src/simpla/predefine/engine/SimpleTimeIntegrator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-5. 3 | 4 | #include "SimpleTimeIntegrator.h" 5 | #include "simpla/engine/Atlas.h" 6 | #include "simpla/engine/Domain.h" 7 | #include "simpla/engine/MeshBlock.h" 8 | namespace simpla { 9 | 10 | SimpleTimeIntegrator::SimpleTimeIntegrator() {} 11 | SimpleTimeIntegrator::~SimpleTimeIntegrator() {} 12 | 13 | void SimpleTimeIntegrator::DoSetUp() { base_type::DoSetUp(); } 14 | void SimpleTimeIntegrator::DoUpdate() { base_type::DoUpdate(); } 15 | void SimpleTimeIntegrator::DoTearDown() { base_type::DoTearDown(); } 16 | 17 | void SimpleTimeIntegrator::Synchronize(int level) { 18 | Update(); 19 | base_type::Synchronize(level); 20 | } 21 | 22 | void SimpleTimeIntegrator::Advance(Real time_now, Real time_dt) { base_type::Advance(time_now, time_dt); } 23 | 24 | } // namespace simpla -------------------------------------------------------------------------------- /test/utilities/log_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * log.cpp 3 | * 4 | * created on: 2013-12-28 5 | * Author: salmon 6 | */ 7 | 8 | #include "../Log.h" 9 | 10 | using namespace simpla; 11 | 12 | int main(int argc, char **argv) 13 | { 14 | logger::init(argc, argv); 15 | 16 | logger::set_stdout_level(29); 17 | int a; 18 | 19 | LOG_CMD(a = 5); 20 | 21 | // log::Logger::set_message_visable_level(10); 22 | 23 | logger::Logger L(logger::LOG_LOG); 24 | 25 | L << "Hello world " << std::endl 26 | 27 | << logger::flush 28 | 29 | << __STRING(a = 5) << "lalalalal"; 30 | 31 | a = 6; 32 | 33 | L << DONE << a << std::endl; 34 | 35 | INFORM << "What?" << std::endl; 36 | INFORM << "Why?" << std::endl; 37 | INFORM << "Who?" << std::endl; 38 | INFORM << "WHen?" << __PRETTY_FUNCTION__ << "[" << __FILE__ << "]" << std::endl; 39 | } 40 | -------------------------------------------------------------------------------- /src/simpla/geometry/Circle.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #include "Circle.h" 6 | #include "Edge.h" 7 | #include "Face.h" 8 | #include "gCircle.h" 9 | #include "gSurface.h" 10 | namespace simpla { 11 | namespace geometry { 12 | SP_GEO_OBJECT_REGISTER(Circle) 13 | SP_GEO_OBJECT_REGISTER(Disk) 14 | Circle::Circle(Axis const &axis, Real radius, std::tuple const &r) : Edge(axis, gCircle::New(radius), r) {} 15 | Circle::Circle(Axis const &axis, Real radius, Real a1) : Edge(axis, gCircle::New(radius), std::make_tuple(0, a1)) {} 16 | 17 | Disk::Disk(Axis const &axis, std::tuple const &b) : Face(axis, gDisk::New(), b) {} 18 | Disk::Disk(Axis const &axis, Real radius, Real a1) 19 | : Disk(axis, std::make_tuple(point2d_type{0, radius}, point2d_type{0, a1})) {} 20 | } // namespace geometry { 21 | } // namespace simpla { -------------------------------------------------------------------------------- /scripts/configure/mesh.xmf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 0 1 7 6 3 4 10 9 6 | 1 2 8 7 4 5 11 10 7 | 8 | 9 | 10 | 12 | 0.0 0.0 1.0 13 | 1.0 0.0 1.0 14 | 3.0 0.0 2.0 15 | 16 | 0.0 1.0 1.0 17 | 1.0 1.0 1.0 18 | 3.0 2.0 2.0 19 | 20 | 0.0 0.0 -1.0 21 | 1.0 0.0 -1.0 22 | 3.0 0.0 -2.0 23 | 24 | 0.0 1.0 -1.0 25 | 1.0 1.0 -1.0 26 | 3.0 2.0 -2.0 27 | 28 | 29 | -------------------------------------------------------------------------------- /CMake/utils.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | function(simpla_test name) 4 | add_executable(${name} ${ARGN}) 5 | if (BUILD_SHARED_LIBS) 6 | set_target_properties(${name} 7 | PROPERTIES 8 | COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1 GTEST_HAS_TR1_TUPLE=0 ") 9 | endif () 10 | 11 | target_link_libraries(${name} ${GTEST_BOTH_LIBRARIES} pthread) 12 | GTEST_ADD_TESTS(${name} "" ${ARGN}) 13 | # ADD_DEPENDENCIES(${GetPrefix} googletest) 14 | # ADD_DEPENDENCIES(alltest ${GetPrefix} ) 15 | endfunction() 16 | 17 | MACRO(SUBDIRLIST result curdir) 18 | FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) 19 | FOREACH (child ${children}) 20 | IF (EXISTS ${curdir}/${child}/CMakeLists.txt) 21 | LIST(APPEND dirlist ${child}) 22 | ENDIF () 23 | ENDFOREACH () 24 | SET(${result} ${dirlist}) 25 | ENDMACRO() -------------------------------------------------------------------------------- /src/simpla/geometry/Circle.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-19. 3 | // 4 | 5 | #ifndef SIMPLA_CIRCLE_H 6 | #define SIMPLA_CIRCLE_H 7 | #include 8 | #include "Edge.h" 9 | #include "Face.h" 10 | namespace simpla { 11 | namespace geometry { 12 | struct Circle : public Edge { 13 | SP_GEO_OBJECT_HEAD(Edge, Circle) 14 | 15 | protected: 16 | explicit Circle(Axis const &axis, Real radius, std::tuple const &r); 17 | explicit Circle(Axis const &axis, Real radius, Real a1 = TWOPI); 18 | }; 19 | struct Disk : public Face { 20 | SP_GEO_OBJECT_HEAD(Face, Disk) 21 | 22 | protected: 23 | explicit Disk(Axis const &axis, std::tuple const &b); 24 | explicit Disk(Axis const &axis, Real radius, Real a1 = TWOPI); 25 | }; 26 | } // namespace geometry{ 27 | } // namespace simpla{ 28 | #endif // SIMPLA_CIRCLE_H 29 | -------------------------------------------------------------------------------- /src/simpla/geometry/gCurve.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-7-26. 3 | // 4 | 5 | #ifndef SIMPLA_CURVE_H 6 | #define SIMPLA_CURVE_H 7 | 8 | #include "GeoEntity.h" 9 | namespace simpla { 10 | namespace geometry { 11 | struct gCurve : public GeoEntity { 12 | SP_GEO_ENTITY_ABS_HEAD(GeoEntity, gCurve) 13 | virtual bool IsClosed() const { return false; } 14 | virtual point_type xyz(Real u) const = 0; 15 | point_type xyz(Real u, Real v, Real w) const override { return xyz(u); }; 16 | }; 17 | 18 | struct gCurve2D : public gCurve { 19 | SP_GEO_ENTITY_ABS_HEAD(gCurve, gCurve2D) 20 | 21 | virtual point2d_type xy(Real u) const = 0; 22 | point_type xyz(Real u) const override { 23 | point_type p{0, 0, 0}; 24 | p = xy(u); 25 | return std::move(p); 26 | }; 27 | }; 28 | 29 | } // namespace geometry 30 | } // namespace simpla 31 | 32 | #endif // SIMPLA_CURVE_H 33 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" ON) 2 | 3 | if(BUILD_DOCUMENTATION) 4 | FIND_PACKAGE(Doxygen) 5 | if (NOT DOXYGEN_FOUND) 6 | message(FATAL_ERROR 7 | "Doxygen is needed to build the documentation. Please install it correctly") 8 | endif() 9 | 10 | #-- Configure the Template Doxyfile for our specific project 11 | configure_file(Doxyfile.in 12 | ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) 13 | #-- AddEntity a custom target to run Doxygen when ever the project is built 14 | add_custom_target (docs ALL 15 | COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile 16 | SOURCES ${PROJECT_BINARY_DIR}/Doxyfile) 17 | # IF you do NOT want the documentation to be generated EVERY time you build the project 18 | # then leave out the 'ALL' keyword from the above command. 19 | endif() 20 | -------------------------------------------------------------------------------- /src/simpla/data/backend/DataBaseMDS.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-15. 3 | // 4 | 5 | #include "DataBaseMDS.h" 6 | 7 | #include "../DataEntry.h" 8 | namespace simpla { 9 | namespace data { 10 | REGISTER_CREATOR(DataBaseMDS, mds); 11 | 12 | struct DataBaseMDS::pimpl_s {}; 13 | DataBaseMDS::DataBaseMDS() : m_pimpl_(new pimpl_s) {} 14 | DataBaseMDS::~DataBaseMDS() { delete m_pimpl_; } 15 | 16 | int DataBaseMDS::Connect(std::string const& authority, std::string const& path, std::string const& query, 17 | std::string const& fragment) { 18 | return SP_SUCCESS; 19 | } 20 | int DataBaseMDS::Disconnect() { return SP_SUCCESS; } 21 | int DataBaseMDS::Flush() { return SP_SUCCESS; } 22 | bool DataBaseMDS::isNull() const { return true; } 23 | 24 | std::shared_ptr DataBaseMDS::Root() { return DataEntry::New(); } 25 | 26 | } // namespace data { 27 | } // namespace simpla { 28 | -------------------------------------------------------------------------------- /external_project/SAMRAI/SAMRAIConfig.cmake.in: -------------------------------------------------------------------------------- 1 | SET(SAMRAI_FOUND TRUE) 2 | SET(SAMRAI_DIR @CMAKE_INSTALL_PREFIX@) 3 | SET(SAMRAI_INCLUDE_DIRS @SAMRAI_INCLUDE_DIRS_DEP@ @CMAKE_INSTALL_PREFIX@/include ) 4 | SET(SAMRAI_LIBRARY_DIRS @SAMRAI_LIBRARY_DIRS_DEP@ @CMAKE_INSTALL_PREFIX@/lib) 5 | SET(SAMRAI_LIBRARIES @SAMRAI_LIBRARIES_DEP@ ) 6 | 7 | SET(SAMRAI_LIBRARIES_LIST 8 | SAMRAI_algs 9 | SAMRAI_appu 10 | SAMRAI_geom 11 | SAMRAI_math 12 | SAMRAI_mesh 13 | SAMRAI_pdat 14 | SAMRAI_solv 15 | SAMRAI_hier 16 | SAMRAI_tbox 17 | SAMRAI_xfer 18 | ) 19 | 20 | FOREACH (LIB_ ${SAMRAI_LIBRARIES_LIST}) 21 | find_library(${LIB_}_FILE NAMES ${LIB_} PATHS ${SAMRAI_LIBRARY_DIRS}) 22 | IF (NOT ${LIB_}_FILE-NOTFOUND) 23 | LIST(APPEND SAMRAI_LIBRARIES ${${LIB_}_FILE}) 24 | ENDIF (NOT ${LIB_}_FILE-NOTFOUND) 25 | ENDFOREACH (LIB_ ${SAMRAI_LIBRARIES_LIST}) -------------------------------------------------------------------------------- /test/data/Configurable_dummy.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-21. 3 | // 4 | #include 5 | #include 6 | #include 7 | struct ConfigurableDummy : public simpla::data::Configurable, public simpla::data::Serializable { 8 | SP_PROPERTY(int, A) = 1; 9 | SP_PROPERTY(double, B) = 2; 10 | }; 11 | 12 | int main(int argc, char** argv) { 13 | ConfigurableDummy dummy; 14 | dummy.SetA(1234455); 15 | dummy.SetProperty("justATest", "hello world!"); 16 | std::cout << "Dummy:" << dummy << std::endl; 17 | 18 | std::cout << " A = " << dummy.GetProperty("A") << " = " << dummy.GetA() << " = " << dummy.m_A_ << std::endl; 19 | std::cout << " B = " << dummy.GetProperty("B") << " = " << dummy.GetB() << " = " << dummy.m_B_ << std::endl; 20 | std::cout << " justATest = " << dummy.GetProperty("justATest") << std::endl; 21 | } -------------------------------------------------------------------------------- /CMake/FindNumPy.cmake: -------------------------------------------------------------------------------- 1 | #- Find NumPy 2 | # INPUT: 3 | # PYTHON_EXECUTABLE 4 | # This module will define the following variable: 5 | # OUTPUT: 6 | # PYTHON_NUMPY_INCLUDE_DIRS 7 | 8 | if(PYTHON_NUMPY_INCLUDE_DIRS ) 9 | #DO NOTHING 10 | else() 11 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c 12 | " 13 | try: 14 | import sys,numpy 15 | sys.stdout.write(numpy.get_include()) 16 | except: 17 | sys.stdout.write('PYTHON_NUMPY_INCLUDE_DIRS-NOTFOUND') 18 | " 19 | OUTPUT_VARIABLE _RES 20 | ) 21 | find_path(PYTHON_NUMPY_INCLUDE_DIRS 22 | NAMES numpy/arrayobject.h 23 | HINTS ${_RES} 24 | NO_DEFAULT_PATH 25 | NO_CMAKE_ENVIRONMENT_PATH 26 | NO_CMAKE_PATH 27 | NO_SYSTEM_ENVIRONMENT_PATH 28 | NO_CMAKE_SYSTEM_PATH 29 | ) 30 | endif() 31 | 32 | 33 | INCLUDE(FindPackageHandleStandardArgs) 34 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( NumPy DEFAULT_MSG PYTHON_NUMPY_INCLUDE_DIRS ) 35 | -------------------------------------------------------------------------------- /src/simpla/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | FILE(GLOB utilities_SRC *.cpp *.h ) 4 | add_library(utilities ${utilities_SRC} ) 5 | target_link_libraries(utilities ${LUA_LIBRARIES} ) 6 | 7 | #${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${TBB_LIBRARIES} 8 | ########################################################### 9 | #IF (DEFINED ENV{LUA_ROOT}) 10 | # 11 | # SetEntity(LUA_ROOT $ENV{LUA_ROOT}) 12 | # 13 | # find_path(LUA_INCLUDE_DIR 14 | # NAMES lua.h 15 | # HINTS ${MPI_ROOT}/include/ 16 | # DOC "MPI header file path" 17 | # ) 18 | # SET(LUA_LIBRARY_DIRS ${LUA_ROOT}/lib/) 19 | # 20 | # find_library(LUA_LIBRARY liblua.a HINTS ${LUA_LIBRARY_DIRS}) 21 | # 22 | # SET(LUA_LIBRARIES ${LUA_LIBRARY}) 23 | # 24 | # FIND_PACKAGE_HANDLE_STANDARD_ARGS(LUA DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIRS LUA_ROOT) 25 | 26 | # 27 | #add_library(lua_parser LuaObject.cpp ConfigParser.cpp) 28 | #target_link_libraries(lua_parser ${LUA_LIBRARIES}) 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/data/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | simpla_test(DataEntry_test DataEntry_test.cpp) 2 | target_link_libraries(DataEntry_test 3 | -Wl,--whole-archive 4 | data data_backend utilities 5 | -Wl,--no-whole-archive 6 | 7 | ) 8 | simpla_test(SPObject_test SPObject_test.cpp ) 9 | 10 | target_link_libraries(SPObject_test 11 | -Wl,--whole-archive 12 | data data_backend 13 | -Wl,--no-whole-archive 14 | 15 | ) 16 | add_executable(Configurable_dummy Configurable_dummy.cpp) 17 | target_link_libraries(Configurable_dummy 18 | -Wl,--whole-archive 19 | data data_backend 20 | -Wl,--no-whole-archive 21 | 22 | ) 23 | #SET(XML2_DIR ${PROJECT_SOURCE_DIR}/external_project/xdmf) 24 | #SET(XDMF_DIR ${PROJECT_SOURCE_DIR}/external_project/xdmf) 25 | #FIND_PACKAGE(XDMF) 26 | # 27 | #ADD_EXECUTABLE(XDMF_dummy XDMF_dummy.cpp) 28 | #target_include_directories(XDMF_dummy BEFORE PRIVATE ${XDMF_INCLUDE_DIRS} ) 29 | #target_link_libraries(XDMF_dummy ${XDMF_LIBRARIES} ) -------------------------------------------------------------------------------- /src/simpla/geometry/csCartesian.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-7-22. 3 | // 4 | #include "csCartesian.h" 5 | #include 6 | #include "Box.h" 7 | #include "Edge.h" 8 | #include "Face.h" 9 | #include "Line.h" 10 | #include "Rectangle.h" 11 | #include "Solid.h" 12 | #include "gCurve.h" 13 | namespace simpla { 14 | namespace geometry { 15 | csCartesian::csCartesian() = default; 16 | csCartesian::csCartesian(csCartesian const &) = default; 17 | csCartesian::~csCartesian() = default; 18 | 19 | std::shared_ptr csCartesian::GetCoordinateEdge(point_type const &o, int normal, Real u) const { 20 | return Line::New(m_axis_); 21 | }; 22 | std::shared_ptr csCartesian::GetCoordinateFace(point_type const &o, int normal, Real u, Real v) const { 23 | return Rectangle::New(m_axis_, std::make_tuple(point2d_type{0.0, u}, point2d_type{0.0, v})); 24 | }; 25 | std::shared_ptr csCartesian::GetCoordinateBox(box_type const &b) const { return Box::New(b); } 26 | } // namespace geometry 27 | } // namespace simpla 28 | -------------------------------------------------------------------------------- /test/algebra/field_basic_algebra_test.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file field_basic_algebra_test.cpp 3 | * 4 | * Created on: Oct 11, 2014 5 | * Author: salmon 6 | */ 7 | 8 | #include "field_basic_algebra_test.h" 9 | #include 10 | #include "simpla/predefine/mesh/CartesianGeometry.h" 11 | typedef simpla::mesh::CartesianGeometry mesh_type; 12 | 13 | using namespace simpla; 14 | 15 | typedef testing::Types< // 16 | Field, // 17 | Field, // 18 | Field, // 19 | Field, // 20 | Field // , 21 | // Field, // 22 | // Field, // 23 | // Field // 24 | > 25 | TypeParamList; 26 | 27 | INSTANTIATE_TYPED_TEST_CASE_P(FIELD, TestField, TypeParamList); 28 | -------------------------------------------------------------------------------- /test/particle/Particle_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-9. 3 | // 4 | 5 | #include "simpla/particle/Particle.h" 6 | #include "simpla/engine/Mesh.h" 7 | #include "simpla/geometry/csCartesian.h" 8 | #include "simpla/mesh/RectMesh.h" 9 | #include "simpla/scheme/FVM.h" 10 | using namespace simpla; 11 | using namespace simpla::data; 12 | typedef engine::Mesh DummyMesh; 13 | int main(int argc, char** argv) { 14 | DummyMesh m; 15 | 16 | Particle p{&m, 7, "m"_ = 1.0, "q"_ = -1.0}; 17 | 18 | Field E{&m, "name"_ = "E"}; 19 | Field B{&m, "name"_ = "B"}; 20 | Field J{&m, "name"_ = "J"}; 21 | Field rho{&m, "name"_ = "B"}; 22 | Field FLUX{&m, "name"_ = "FLUX"}; 23 | 24 | p.db()->Serialize(std::cout, 0); 25 | std::cout << std::endl; 26 | p.Initialize(); 27 | p.InitialLoad(); 28 | p.Sort(); 29 | // p.Load(200); 30 | } -------------------------------------------------------------------------------- /src/simpla/engine/backend/SAMRAITimeIntegrator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-5-31. 3 | // 4 | 5 | #ifndef SIMPLA_SAMRAITIMEINTEGRATOR_H 6 | #define SIMPLA_SAMRAITIMEINTEGRATOR_H 7 | #include "simpla/SIMPLA_config.h" 8 | #include "simpla/algebra/Algebra.h" 9 | #include "simpla/data/Data.h" 10 | #include "simpla/engine/TimeIntegrator.h" 11 | namespace simpla { 12 | 13 | /** 14 | * class SAMRAITimeIntegrator 15 | */ 16 | struct SAMRAITimeIntegrator : public engine::TimeIntegrator { 17 | SP_OBJECT_HEAD(SAMRAITimeIntegrator, engine::TimeIntegrator); 18 | 19 | public: 20 | void DoInitialize() override; 21 | void DoFinalize() override; 22 | void DoUpdate() override; 23 | void DoTearDown() override; 24 | 25 | void Synchronize(int level) override; 26 | void Advance(Real time_now, Real time_dt) override; 27 | bool Done() const override; 28 | 29 | void CheckPoint(size_type step_num) const override; 30 | void Dump() const override; 31 | }; 32 | 33 | } // namespace simpla{ 34 | #endif // SIMPLA_SAMRAITIMEINTEGRATOR_H 35 | -------------------------------------------------------------------------------- /docs/latex_header.tex: -------------------------------------------------------------------------------- 1 | \documentclass[english]{beamer} 2 | \usepackage{fontspec} 3 | \setmainfont[Mapping=tex-text]{Latin Modern Roman} 4 | \setsansfont[Mapping=tex-text]{Noto Sans CJK SC} 5 | \setmonofont{Noto Sans Mono CJK SC} 6 | \setcounter{secnumdepth}{3} 7 | \setcounter{tocdepth}{3} 8 | 9 | \makeatletter 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. 11 | % this default might be overridden by plain title style 12 | \newcommand\makebeamertitle{\frame{\maketitle}}% 13 | % (ERT) argument for the TOC 14 | \AtBeginDocument{% 15 | \let\origtableofcontents=\tableofcontents 16 | \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}} 17 | \def\gobbletableofcontents#1{\origtableofcontents} 18 | } 19 | 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. 21 | \usepackage[CJKnumber]{xeCJK} 22 | 23 | \usetheme{CambridgeUS} 24 | 25 | \usefonttheme[onlymath]{serif} 26 | 27 | \makeatother 28 | 29 | \usepackage{xunicode} 30 | \usepackage{polyglossia} 31 | \setdefaultlanguage[variant=american]{english} -------------------------------------------------------------------------------- /src/simpla/geometry/gSurface.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-19. 3 | // 4 | 5 | #ifndef SIMPLA_GSURFACE_H 6 | #define SIMPLA_GSURFACE_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include "GeoEntity.h" 12 | 13 | namespace simpla { 14 | namespace geometry { 15 | 16 | /** 17 | * a surface is a generalization of a plane which needs not be flat, that is, the curvature is not necessarily zero. 18 | */ 19 | struct gSurface : public GeoEntity { 20 | SP_GEO_ENTITY_ABS_HEAD(GeoEntity, gSurface); 21 | virtual bool IsClosed() const { return false; } 22 | point_type xyz(Real u, Real v, Real w) const override { return xyz(u, v); } 23 | virtual point_type xyz(Real u, Real v) const = 0; 24 | point_type xyz(point2d_type const& p) const { return xyz(p[0], p[1]); }; 25 | }; 26 | 27 | // struct gPlane : public ParametricSurface2D { 28 | // SP_GEO_ENTITY_ABS_HEAD(ParametricSurface2D, gPlane) 29 | // point2d_type xy(Real u, Real v) const override { return point2d_type{(u), (v)}; }; 30 | //}; 31 | } // namespace geometry 32 | } // namespace simpla 33 | #endif // SIMPLA_GSURFACE_H 34 | -------------------------------------------------------------------------------- /src/simpla/geometry/gCircle.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-22. 3 | // 4 | 5 | #ifndef SIMPLA_GCIRCLE_H 6 | #define SIMPLA_GCIRCLE_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include "GeoEntity.h" 12 | #include "gCone.h" 13 | #include "gPlane.h" 14 | #include "gSurface.h" 15 | namespace simpla { 16 | namespace geometry { 17 | struct gCircle : public gConic { 18 | SP_GEO_ENTITY_HEAD(gConic, gCircle, Circle); 19 | explicit gCircle(Real radius) : m_Radius_(radius) {} 20 | bool IsClosed() const override { return true; } 21 | SP_PROPERTY(Real, Radius) = 1.0; 22 | 23 | point2d_type xy(Real alpha) const override { 24 | return point2d_type{m_Radius_ * std::cos(alpha), m_Radius_ * std::sin(alpha)}; 25 | }; 26 | }; 27 | 28 | struct gDisk : public gPlane { 29 | SP_GEO_ENTITY_HEAD(gPlane, gDisk, Disk); 30 | point2d_type xy(Real r, Real alpha) const override { 31 | return point2d_type{r * std::cos(alpha), r * std::sin(alpha)}; 32 | }; 33 | }; 34 | } // namespace geometry{ 35 | } // namespace simpla{ 36 | 37 | #endif // SIMPLA_GCIRCLE_H 38 | -------------------------------------------------------------------------------- /src/simpla/numeric/Integration.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file integration.h 3 | * 4 | * created on: 2013-12-2 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef INTEGRATION_H_ 9 | #define INTEGRATION_H_ 10 | 11 | #include 12 | 13 | namespace simpla 14 | { 15 | 16 | /** @ingroup numeric*/ 17 | 18 | template 19 | inline std::map()*std::declval())> // 20 | Integrate(std::map const & xy) 21 | { 22 | typedef decltype( std::declval()*std::declval()) res_value_type; 23 | typedef std::map res_type; 24 | typedef typename std::map::iterator iterator; 25 | typedef TX x_type; 26 | typedef TY y_type; 27 | 28 | res_value_type f = 0; 29 | 30 | res_type res; 31 | 32 | res.emplace(std::make_pair(xy.begin()->first, f)); 33 | 34 | for (iterator it1 = xy.begin(), it2 = it1++; it2 != xy.end(); ++it1, ++it2) 35 | { 36 | f += 0.5 * (it1->second + it2->second) * (it2->first - it1->first); 37 | res.emplace(std::make_pair(it2->first, f)); 38 | } 39 | 40 | return std::move(res); 41 | } 42 | 43 | } 44 | // namespace simpla 45 | 46 | #endif /* INTEGRATION_H_ */ 47 | -------------------------------------------------------------------------------- /test/data/SPObject_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-2-13. 3 | // 4 | #include 5 | 6 | #include 7 | #include "simpla/data/Data.h" 8 | using namespace simpla; 9 | using namespace simpla::data; 10 | struct DummyObject : public SPObject { 11 | SP_OBJECT_HEAD(DummyObject, SPObject) 12 | SP_PROPERTY(Real, Mass); 13 | SP_PROPERTY(Real, Charge); 14 | }; 15 | DummyObject::DummyObject() = default; 16 | DummyObject::~DummyObject() = default; 17 | 18 | std::shared_ptr DummyObject::Serialize() const { return base_type::Serialize(); }; 19 | void DummyObject::Deserialize(std::shared_ptr const& cfg) { base_type::Deserialize(cfg); }; 20 | SP_GEO_OBJECT_REGISTER(DummyObject) 21 | TEST(SPObject, Dummy) { 22 | auto objA = DummyObject::New(); 23 | objA->SetMass(1.0); 24 | objA->SetCharge(-1.0); 25 | std::cout << *objA->Serialize() << std::endl; 26 | 27 | auto objB = std::dynamic_pointer_cast(SPObject::New(objA->Serialize())); 28 | EXPECT_TRUE(objB != nullptr); 29 | EXPECT_DOUBLE_EQ(objA->GetMass(), objB->GetMass()); 30 | EXPECT_DOUBLE_EQ(objA->GetCharge(), objB->GetCharge()); 31 | } 32 | -------------------------------------------------------------------------------- /test/utilities/memory_pool_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * memory_pool_test.cpp 3 | * 4 | * Created on: 2014-11-14 5 | * Author: salmon 6 | */ 7 | 8 | #include 9 | #include 10 | #include "memory_pool.h" 11 | #include "log.h" 12 | #include "../io/DataStream.h" 13 | #include "../parallel/MPIComm.h" 14 | 15 | using namespace simpla; 16 | 17 | /// TODO need a multithead test of memory pool 18 | 19 | int main(int argc, char **argv) 20 | { 21 | LOGGER.init(argc, argv); 22 | GLOBAL_COMM.init(argc,argv); 23 | GLOBAL_DATA_STREAM.init(argc,argv); 24 | 25 | // std::shared_ptr p[10]; 26 | // 27 | // SingletonHolder::instance().max_size(4000); 28 | // for (int i = 0; i < 10; ++i) 29 | // { 30 | // p[i] = sp_make_shared_array(100); 31 | // 32 | // std::cout << SingletonHolder::instance().size() 33 | // << std::endl; 34 | // } 35 | // 36 | // for (int i = 0; i < 10; ++i) 37 | // { 38 | // p[i].reset(); 39 | // 40 | // std::cout << SingletonHolder::instance().size() 41 | // << std::endl; 42 | // } 43 | // 44 | // std::cout << " " << std::setw(25) << std::left << "hello" << " " 45 | // << std::left << "world!" << std::endl; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /test/algebra/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | simpla_test(field_basic_algebra_test field_basic_algebra_test.cpp) 3 | target_link_libraries(field_basic_algebra_test mesh utilities) 4 | # 5 | simpla_test(field_diff_calculus_cartesian_test field_diff_calculus_test.cpp) 6 | #target_compile_options(field_diff_calculus_cartesian_test PUBLIC -DCARTESIAN_COORDINATE_SYSTEM) 7 | target_link_libraries(field_diff_calculus_cartesian_test mesh utilities) 8 | 9 | simpla_test(field_aritmetic_test field_aritmetic_test.cpp) 10 | 11 | 12 | add_executable(field_dummy field_dummy.cpp ) 13 | target_link_libraries(field_dummy 14 | netcdf ${HDF5_LIBRARIES} ${MPI_C_LIBRARIES} ${TBB_LIBRARIES} 15 | -Wl,--whole-archive utilities data 16 | -Wl,--no-whole-archive ${OPENMP_LIBRARIES} ${CUDA_LIBRARIES} 17 | ) 18 | 19 | 20 | simpla_test(ntuple_test ntuple_test.cpp) 21 | simpla_test(array_test array_test.cpp) 22 | 23 | 24 | add_executable(ntuple_dummy ntuple_dummy.cpp) 25 | 26 | 27 | add_executable(ntuple_bench ntuple_bench.cpp) 28 | target_link_libraries(ntuple_bench benchmark pthread) 29 | 30 | add_executable(array_dummy array_dummy.cpp) 31 | target_link_libraries(array_dummy utilities ) 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/simpla/data/Serializable.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-17. 3 | // 4 | 5 | #include "Serializable.h" 6 | #include "Configurable.h" 7 | #include "DataEntry.h" 8 | namespace simpla { 9 | namespace data { 10 | Serializable::Serializable() = default; 11 | Serializable::Serializable(Serializable const &) = default; 12 | Serializable::~Serializable() = default; 13 | void Serializable::Deserialize(std::shared_ptr const &cfg) { 14 | if (auto *config = dynamic_cast(this)) { config->Push(cfg); } 15 | } 16 | std::shared_ptr Serializable::Serialize() const { 17 | auto res = DataEntry::New(DataEntry::DN_TABLE); 18 | res->SetValue("_TYPE_", FancyTypeName()); 19 | if (auto const *config = dynamic_cast(this)) { config->Pop(res); } 20 | return res; 21 | }; 22 | 23 | std::ostream &operator<<(std::ostream &os, Serializable const &obj) { 24 | os << *obj.Serialize(); 25 | return os; 26 | } 27 | std::istream &operator>>(std::istream &is, Serializable &obj) { 28 | auto db = DataEntry::New(DataEntry::DN_TABLE); 29 | is >> *db; 30 | obj.Deserialize(db); 31 | return is; 32 | } 33 | } // namespace geometry 34 | } // namespace simpla -------------------------------------------------------------------------------- /external_project/IMAS/INSTALL.md: -------------------------------------------------------------------------------- 1 | #Pre-Require 2 | python-numpy cython libsaxonhe-java 3 | 4 | #ENV 5 | ``` 6 | export CLASSPATH=/usr/share/java/saxon9he.jar 7 | export PKG_CONFIG_PATH=/usr/lib/pkgconfig/ 8 | ``` 9 | #Build 10 | ``` 11 | WORK_DIR=/work/imas 12 | 13 | cd $WORK_DIR/ 14 | 15 | git clone ssh://git@git.iter.org/imas/installer.git 16 | git clone ssh://git@git.iter.org/imex/kepler-installer.git 17 | 18 | 19 | module load Blitz++/0.10 MDSplus/6.1.84 Python/2.7 Java/1.8 intel/2016 20 | 21 | export IMAS_HOME=/pkg/imas 22 | export UAL_VERSION=3.4.0 23 | export IMAS_VERSION=3.7.4 24 | 25 | cd $WORK_DIR/installer 26 | 27 | make update 28 | make version 29 | make dd 30 | MATLAB=no PGI=no make ual -j8 31 | make install 32 | make module_install 33 | 34 | cd $WORK_DIR/kepler-installer 35 | 36 | ./install-kepler-2.5-bare.sh /pkg/imas/extra/kepler/2.5-imas-3.7.4 37 | 38 | export KEPLER=/pkg/imas/extra/kepler/2.5-imas-3.7.4 39 | 40 | ./install-kepler-modules.sh /pkg/imas/extra/ /pkg/imas/etc/modulefiles/ 41 | ``` 42 | # Run 43 | ``` 44 | module load ant/1.9.6 45 | module load kepler/2.5-imas-3.7.4 46 | 47 | cd $IMAS_HOME/extra/ 48 | git clone ssh://git@git.iter.org/imex/fc2k.git 49 | cd $IMAS_HOME/extra/fc2k 50 | ant jar 51 | ``` -------------------------------------------------------------------------------- /src/simpla/geometry/gCylinder.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-7-22. 3 | // 4 | 5 | #ifndef SIMPLA_GCYLINDRICAL_H 6 | #define SIMPLA_GCYLINDRICAL_H 7 | 8 | #include 9 | #include 10 | #include "gBody.h" 11 | #include "gCone.h" 12 | #include "gSurface.h" 13 | 14 | namespace simpla { 15 | namespace geometry { 16 | /** 17 | * R phi Z 18 | */ 19 | struct gCylinder : public gBody { 20 | SP_GEO_ENTITY_HEAD(gBody, gCylinder, Cylinder) 21 | explicit gCylinder(Real radius) : m_Radius_(radius) {} 22 | SP_PROPERTY(Real, Radius) = 1.0; 23 | point_type xyz(Real u, Real v, Real w) const override { return point_type{u * std::cos(v), u * std::sin(v), w}; }; 24 | }; 25 | struct gCylindricalSurface : public gConicSurface { 26 | SP_GEO_ENTITY_HEAD(gConicSurface, gCylindricalSurface, CylindricalSurface) 27 | explicit gCylindricalSurface(Real radius) : m_Radius_(radius) {} 28 | SP_PROPERTY(Real, Radius) = 1.0; 29 | point_type xyz(Real v, Real w) const override { 30 | return point_type{m_Radius_ * std::cos(v), m_Radius_ * std::sin(v), w}; 31 | }; 32 | }; 33 | 34 | } // namespace geometry 35 | } // namespace simpla 36 | 37 | #endif // SIMPLA_GCYLINDRICAL_H 38 | -------------------------------------------------------------------------------- /src/simpla/data/backend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #FIND_PACKAGE(VTK) 2 | #MESSAGE("-- VTK version: ${VTK_VERSION}") 3 | #SET(XML2_DIR ${PROJECT_SOURCE_DIR}/external_project/xdmf) 4 | #SET(XDMF_DIR ${PROJECT_SOURCE_DIR}/external_project/xdmf) 5 | #FIND_PACKAGE(XDMF) 6 | 7 | #FILE(GLOB database_SRC *.cpp *.h ) 8 | 9 | LIST(APPEND data_backend_SRC 10 | DataEntryMemory.h 11 | DataEntryMemory.cpp 12 | DataEntryLua.cpp 13 | DataEntryHDF5.cpp 14 | DataEntryXDMF.cpp 15 | DataEntryIMAS.cpp 16 | HDF5Common.cpp 17 | HDF5Common.h 18 | LuaObject.cpp 19 | LuaObject.h 20 | LuaObjectExt.h 21 | ) 22 | #IF (XDMF_FOUND) 23 | # LIST(APPEND data_backend_SRC DataEntryXDMF3.cpp) 24 | #ENDIF (XDMF_FOUND) 25 | ADD_LIBRARY(data_backend ${data_backend_SRC}) 26 | target_include_directories(data_backend BEFORE PRIVATE 27 | ${HDF5_INCLUDE_DIRS} 28 | ${LUA_INCLUDE_DIR} 29 | ${MPI_C_INCLUDE_PATH} 30 | ${XDMF_INCLUDE_DIRS} 31 | #${VTK_INCLUDE_DIR} 32 | ) 33 | TARGET_LINK_LIBRARIES(data_backend 34 | ${LUA_LIBRARIES} 35 | ${HDF5_LIBRARIES} 36 | ${MPI_LIBRARIES} 37 | ${XDMF_LIBRARIES} 38 | #${VTK_LIBRARIES} 39 | ) -------------------------------------------------------------------------------- /src/simpla/engine/TimeIntegrator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-5. 3 | // 4 | 5 | #ifndef SIMPLA_TIMEINTEGRATOR_H 6 | #define SIMPLA_TIMEINTEGRATOR_H 7 | 8 | #include "Scenario.h" 9 | namespace simpla { 10 | namespace engine { 11 | class TimeIntegrator : public Scenario { 12 | SP_ENABLE_NEW_HEAD(Scenario, TimeIntegrator); 13 | 14 | public: 15 | virtual void InitialCondition(Real time_now); 16 | virtual void BoundaryCondition(Real time_now, Real dt); 17 | virtual void ComputeFluxes(Real time_now, Real time_dt); 18 | virtual Real ComputeStableDtOnPatch(Real time_now, Real time_dt); 19 | virtual void Advance(Real time_now, Real dt); 20 | 21 | void DoSetUp() override; 22 | void DoTearDown() override; 23 | 24 | void Synchronize(int level) override; 25 | void NextStep() override; 26 | void Run() override; 27 | bool Done() const override; 28 | 29 | SP_PROPERTY(size_type, MaxStep); 30 | SP_PROPERTY(Real, CFL); 31 | SP_PROPERTY(Real, TimeNow); 32 | SP_PROPERTY(Real, TimeEnd); 33 | SP_PROPERTY(Real, TimeStep); 34 | 35 | Real GetTime() const override { return GetTimeNow(); }; 36 | }; 37 | } // namespace engine 38 | } // namespace simpla 39 | 40 | #endif // SIMPLA_TIMEINTEGRATOR_H 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SIMPla {#mainpage} 2 | ======================================== 3 | 4 | \b SIMPla is a unified and hierarchical development framework for plasma simulation. “SimPla” is abbreviation of four words, __Simulation__, __Integration__, __Multi-physics__ and __Plasma__. 5 | 6 | 7 | Requirement: 8 | -------------- 9 | - C++ 11, 10 | - Expression Template (Field, nTuple), need gcc >=5 11 | - others, need gcc >= 4.8 12 | - MPI , OpenMPI >1.10.2 13 | - HDF5 >1.8.10 14 | - boost : uuid 15 | - TBB for multi-block_dims 16 | - Lua >5.2 , for lua_parser 17 | - CMake 3.5.1, for building 18 | 19 | 20 | Optional: 21 | -------------- 22 | - google test , for unit test 23 | - CUDA 8, for sp_lite 24 | - liboce >0.17 for modeling 25 | - h5py, matplotlib, to display result 26 | 27 | Build: 28 | -------------- 29 | 30 | $mkdir build 31 | $cd build 32 | $cmake ..// -DCMAKE_BUILD_TYPE=Release 33 | $make 34 | 35 | 36 | 37 | # Document {#detail} 38 | ======================================== 39 | 40 | - @subpage install 41 | - @subpage general_conversions 42 | - @subpage design_document 43 | - @subpage user_guide 44 | 45 | TODO 46 | - AMR 47 | - Embedding boundary 48 | - Physical quantity/units 49 | 50 | 51 | -------------------------------------------------------------------------------- /docs/GeneralConventions.md: -------------------------------------------------------------------------------- 1 | General Conventions {#general_convertions} 2 | ======================================================== 3 | 4 | ## Terminology 5 | 6 | 7 | ### Concept {#concept_desc} 8 | @ref concept_desc :: In generic programming, a @ref concept_desc is a description of supported 9 | operations on a value_type_info, including syntax and semantics. In this way, concepts are related to 10 | abstract base classes but concepts do not require a subtype relationship. 11 | -- [ wiki ](http://en.wikipedia.org/wiki/Concept_(generic_programming) "Concept_(generic_programming)" ) 12 | 13 | 14 | ### 6-dimensional phase-space {#phase_space_6d} 15 | @ref phase_space_6d :: 16 | \f$ \left(x,y,z,v_x,v_y,v_z \right) \f$ 17 | 18 | ### 7-dimensional phase-space {#phase_space_7d} 19 | @ref phase_space_7d :: 20 | \f$ \left(t,x,y,z,v_x,v_y,v_z \right) \f$ 21 | 22 | ### configuration space {#configuration_space} 23 | @ref configuration_space refer to the base manifold of phase-space 24 | 25 | 26 | ### Attribute ,Property , Quality, Quantity 27 | - **Attribute** : The Attribute element defines values associated with the mesh. 28 | - **Property** : a property is a characteristic of an object; 29 | Example: _a red object is said to have the property of redness._ -------------------------------------------------------------------------------- /docs/DevGuide.md: -------------------------------------------------------------------------------- 1 | Develop Guide 2 | ============= 3 | [TOC] 4 | 5 | 6 | ## Name style and directory structure 7 | 8 | * namespace : Namespace names are all lower-case. Top-at_level namespace names are based on the project GetName . 9 | * value_type_info GetName : Type names start with a capital letter and have a capital letter for each new word, with no underscores: MyExcitingClass, MyExcitingEnum. 10 | * file GetName : File are based on the class GetName. 11 | * module : 12 | - Each module have a namespace; 13 | - Each module have a sub-directory, whose GetName is based on module GetName. 14 | Example: 15 | /src/foo_bar/UBarBaz.h: 16 | namespace foo_bar 17 | { 18 | class UBarBaz{ 19 | void balalal(); 20 | }; 21 | } 22 | /src/foo_bar/UBarBaz.cpp: 23 | void foo_bar::UBarBaz::balalal(){ /* do sth.*/} 24 | * class concept: Classes have same prefix, if they are in the same concept 25 | Example: 26 | class WriterHDF5; 27 | class WriterXDMF; 28 | class WriterVTK; 29 | .... 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/simpla/data/Creatable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-20. 3 | // 4 | 5 | #ifndef SIMPLA_CREATABLE_H 6 | #define SIMPLA_CREATABLE_H 7 | 8 | #include 9 | #include 10 | #include "DataEntry.h" 11 | #include "Serializable.h" 12 | namespace simpla { 13 | namespace data { 14 | 15 | template 16 | struct Creatable { 17 | public: 18 | // template 19 | // static std::shared_ptr Create(Args &&... args) { 20 | // return std::shared_ptr(new TObj(std::forward(args)...)); 21 | // } 22 | static std::shared_ptr Create(std::string const &k) { return simpla::Factory::Create(k); } 23 | static std::shared_ptr Create(std::shared_ptr const &k) { 24 | auto res = simpla::Factory::Create(k->GetValue("_REGISTER_NAME_", "")); 25 | if (auto s = std::dynamic_pointer_cast(res)) { s->Deserialize(k); } 26 | return res; 27 | } 28 | template 29 | static std::shared_ptr CreateAs(Args &&... args) { 30 | return std::dynamic_pointer_cast(Create(std::forward(args)...)); 31 | } 32 | }; 33 | } // namespace data { 34 | } // namespace simpla { 35 | 36 | #endif // SIMPLA_CREATABLE_H 37 | -------------------------------------------------------------------------------- /src/simpla/utilities/SingletonHolder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2007-2011 YU Zhi. All rights reserved. 3 | * $Id$ 4 | * @file singleton_holder.h 5 | * 6 | * created on: 2008-04-16 7 | * Author: salmon 8 | */ 9 | #ifndef INCLUDE_SINGLETON_HOLDER_H_ 10 | #define INCLUDE_SINGLETON_HOLDER_H_ 11 | namespace simpla { 12 | 13 | /** @ingroup design_pattern 14 | * 15 | * @addtogroup singleton Singleton 16 | * @{ 17 | * 18 | * @brief singleton 19 | * 20 | * @note Meyers Singleton, 21 | * Ref:Andrei Alexandrescu Chap 6.4 22 | * Modern C++ Design Generic Programming and Design Patterns Applied 2001 Addison Wesley , 23 | */ 24 | template 25 | class SingletonHolder { 26 | public: 27 | static T &instance() { 28 | if (!pInstance_) { 29 | //#pragma omp critical 30 | // TOD add some for mt critical 31 | if (!pInstance_) { 32 | static T tmp; 33 | pInstance_ = &tmp; 34 | } 35 | } 36 | return *pInstance_; 37 | } 38 | 39 | protected: 40 | SingletonHolder() {} 41 | ~SingletonHolder() {} 42 | static T *volatile pInstance_; 43 | }; 44 | 45 | template 46 | T *volatile SingletonHolder::pInstance_ = 0; 47 | 48 | /** @} */ 49 | } // namespace simpla 50 | #endif // INCLUDE_SINGLETON_HOLDER_H_ 51 | -------------------------------------------------------------------------------- /src/simpla/geometry/gSphere.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-23. 3 | // 4 | 5 | #ifndef SIMPLA_GSPHERE_H 6 | #define SIMPLA_GSPHERE_H 7 | 8 | #include 9 | #include "gBody.h" 10 | #include "gSurface.h" 11 | 12 | namespace simpla { 13 | namespace geometry { 14 | 15 | struct gSphere : public gBody { 16 | SP_GEO_ENTITY_HEAD(gBody, gSphere, Sphere) 17 | explicit gSphere(Real radius) : m_Radius_(radius){}; 18 | SP_PROPERTY(Real, Radius) = 1.0; 19 | point_type xyz(Real r, Real phi, Real theta) const override { 20 | Real cos_theta = std::cos(theta); 21 | return point_type{r * cos_theta * std::cos(phi), r * cos_theta * std::sin(phi), r * std::sin(theta)}; 22 | }; 23 | }; 24 | struct gSphereSurface : public gSurface { 25 | SP_GEO_ENTITY_HEAD(gSurface, gSphereSurface, SphereSurface) 26 | explicit gSphereSurface(Real radius) : m_Radius_(radius){}; 27 | SP_PROPERTY(Real, Radius) = 1.0; 28 | point_type xyz(Real phi, Real theta) const override { 29 | Real cos_theta = std::cos(theta); 30 | return point_type{m_Radius_ * cos_theta * std::cos(phi), m_Radius_ * cos_theta * std::sin(phi), 31 | m_Radius_ * std::sin(theta)}; 32 | }; 33 | }; 34 | } // namespace geometry 35 | } // namespace simpla 36 | 37 | #endif // SIMPLA_GSPHERE_H 38 | -------------------------------------------------------------------------------- /src/simpla/data/DataTraits.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-3-8. 3 | // 4 | 5 | #ifndef SIMPLA_DATAENTITYFACTROY_H 6 | #define SIMPLA_DATAENTITYFACTROY_H 7 | 8 | #include 9 | #include 10 | #include "simpla/algebra/nTuple.h" 11 | 12 | namespace simpla { 13 | template 14 | struct nTuple; 15 | namespace data { 16 | class DataEntity; 17 | } // namespace data { 18 | 19 | namespace traits { 20 | template 21 | struct is_light_data : public std::integral_constant::value> {}; 22 | 23 | // template 24 | // struct is_light_data> : public std::true_type {}; 25 | // template 26 | // struct is_light_data> : public std::true_type {}; 27 | template <> 28 | struct is_light_data : public std::integral_constant {}; 29 | template <> 30 | struct is_light_data : public std::integral_constant {}; 31 | template <> 32 | struct is_light_data : public std::integral_constant {}; 33 | 34 | template 35 | struct is_light_data> : public std::integral_constant::value> {}; 36 | } // namespace traits { 37 | 38 | } // namespace simpla { 39 | #endif // SIMPLA_DATAENTITYFACTROY_H 40 | -------------------------------------------------------------------------------- /src/simpla/data/DataUtilities.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-20. 3 | // 4 | 5 | #include "DataBlock.h" 6 | #include "DataEntity.h" 7 | 8 | namespace simpla { 9 | namespace data { 10 | 11 | // std::ostream& DataEntity::Serialize(std::ostream& os, int indent) const { 12 | // if (dynamic_cast(this) != nullptr) { 13 | // os << ""; 14 | // } else if (dynamic_cast(this) != nullptr) { 15 | // os << ""; 16 | // } else if (dynamic_cast(this) != nullptr) { 17 | // os << ""; 18 | // } else { 19 | // os << ""; 20 | // } 21 | // return os; 22 | //}; 23 | 24 | 25 | // DataEntity DataEntity::operator[](std::string const& url) { 26 | // if (m_holder_ == nullptr) { 27 | // m_holder_ = new DataTable; 28 | // } else if (!m_holder_->isA(typeid(DataTable))) { 29 | // RUNTIME_ERROR << "Data entity is not indexable!" << std::endl; 30 | // } 31 | // return static_cast(m_holder_)->Insert(url).first; 32 | //}; 33 | // DataEntity DataEntity::operator[](std::string const& url) const { 34 | // if (!m_holder_->isA(typeid(DataTable))) { RUNTIME_ERROR << "Data entity is not indexable!" << std::endl; } 35 | // return (*static_cast(m_holder_))[url]; 36 | //} 37 | } // namespace get_mesh{ 38 | } // namespace simpla{ -------------------------------------------------------------------------------- /src/simpla/numeric/cholesky.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cholesky.h 3 | * 4 | * created on: 2013-10-22 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef CHOLESKY_H_ 9 | #define CHOLESKY_H_ 10 | #include "simpla/algebra/nTuple.h" 11 | namespace simpla 12 | { 13 | /** 14 | * @ingroup numeric 15 | * cholesky decomposition 16 | * @param a 17 | * @return 18 | */ 19 | template 20 | nTuple && cholesky_decomposition(nTuple &a) 21 | { 22 | /** 23 | * Constructor.Given a positive-definite symmetric matrix 24 | * a[0..n - 1][0..n - 1], construct and store its Cholesky 25 | * decomposition, \f$A= L \cdot L^T\f$. 26 | */ 27 | nTuple el; 28 | 29 | for (int i = 0; i < N; ++i) 30 | for (int j = i; j < N; ++j) 31 | { 32 | T sum = el[i][j]; 33 | for (int k = i - 1; k >= 0; --k) 34 | { 35 | sum -= el[i][k] * el[j][k]; 36 | } 37 | if (i == j) 38 | { 39 | if (sum <= 0.0) // A, with rounding errors, is not positive-definite. 40 | throw("Cholesky failed"); 41 | 42 | el[i][i] = sqrt(sum); 43 | } 44 | else 45 | { 46 | el[j][i] = sum / el[i][i]; 47 | } 48 | } 49 | 50 | for (int i = 0; i < N; ++i) 51 | for (int j = 0; j < i; ++j) 52 | { 53 | el[j][i] = 0.; 54 | } 55 | 56 | return std::move(el); 57 | } 58 | 59 | } // namespace simpla 60 | 61 | #endif /* CHOLESKY_H_ */ 62 | -------------------------------------------------------------------------------- /src/simpla/predefine/device/ExtraSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-5-30. 3 | // 4 | 5 | #ifndef SIMPLA_EXTRASOURCE_H 6 | #define SIMPLA_EXTRASOURCE_H 7 | 8 | #include "simpla/SIMPLA_config.h" 9 | #include "simpla/engine/Engine.h" 10 | #include "simpla/physics/PhysicalConstants.h" 11 | 12 | namespace simpla { 13 | 14 | using namespace data; 15 | using namespace engine; 16 | 17 | template 18 | class ExtraSource { 19 | public: 20 | SP_ENGINE_POLICY_HEAD(ExtraSource); 21 | 22 | void Serialize(data::DataTable* res) const; 23 | void Deserialize(std::shared_ptr const& cfg); 24 | 25 | void InitialCondition(Real time_now); 26 | void BoundaryCondition(Real time_now, Real dt); 27 | void Advance(Real time_now, Real dt); 28 | 29 | std::shared_ptr m_attrr_; 30 | }; 31 | 32 | template 33 | void ExtraSource::Serialize(data::DataTable* res) const {}; 34 | 35 | template 36 | void ExtraSource::Deserialize(std::shared_ptr const& cfg) {} 37 | 38 | template 39 | void ExtraSource::InitialCondition(Real time_now) {} 40 | template 41 | void ExtraSource::BoundaryCondition(Real time_now, Real dt) {} 42 | template 43 | void ExtraSource::Advance(Real time_now, Real dt) {} 44 | 45 | } // namespace simpla; 46 | #endif // SIMPLA_EXTRASOURCE_H 47 | -------------------------------------------------------------------------------- /scripts/PostProcesse/particle.xdmf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/simpla/numeric/half_split.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file half_split.h 3 | * 4 | * Created on: 2014-12-10 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef CORE_NUMERIC_HALF_SPLIT_H_ 9 | #define CORE_NUMERIC_HALF_SPLIT_H_ 10 | 11 | namespace simpla 12 | { 13 | template 14 | std::tuple half_split(std::tuple & range) 15 | { 16 | std::tuple res = range; 17 | range = tmp / 2; 18 | return tmp - range; 19 | } 20 | template 21 | nTuple half_split(nTuple & range) 22 | { 23 | nTuple res; 24 | res = range; 25 | 26 | auto n = max_at(res); 27 | 28 | res[n] = half_split(range[n]); 29 | 30 | return std::move(res); 31 | } 32 | //template 33 | //std::vector> split(T const start, T const & size, size_t num) 34 | //{ 35 | // nTuple res; 36 | // res = entity_id_range; 37 | // 38 | // auto n = max_at(res); 39 | // 40 | // res[n] = half_split(entity_id_range[n]); 41 | // 42 | // return std::Move(res); 43 | //} 44 | //template 45 | //std::vector> split(nTuple const & entity_id_range, size_t num) 46 | //{ 47 | // nTuple res; 48 | // res = entity_id_range; 49 | // 50 | // auto n = max_at(res); 51 | // 52 | // res[n] = half_split(entity_id_range[n]); 53 | // 54 | // return std::Move(res); 55 | //} 56 | } // namespace simpla 57 | 58 | #endif /* CORE_NUMERIC_HALF_SPLIT_H_ */ 59 | -------------------------------------------------------------------------------- /test/data/XDMF_dummy.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-14. 3 | // 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int main(int argc, char** argv) { 12 | auto domain = XdmfDomain::New(); 13 | auto grid_collection = XdmfGridCollection::New(); 14 | auto grid_curv = XdmfCurvilinearGrid::New(4, 2, 2); 15 | grid_curv->setName("Curv"); 16 | auto geo = XdmfGeometry::New(); 17 | geo->setType(XdmfGeometryType::XYZ()); 18 | geo->setOrigin(0, 0, 0); 19 | double x[4 * 2 * 2]; 20 | double y[4 * 2 * 2]; 21 | double z[4 * 2 * 2]; 22 | for (int i = 0; i < 4 * 2 * 2; ++i) { 23 | x[i] = i % 4; 24 | y[i] = i % 2; 25 | z[i] = i % 2; 26 | } 27 | 28 | std::vector dimensions = {4, 2, 2, 3}; 29 | geo->initialize(XdmfArrayType::Float64(), dimensions); 30 | geo->insert(0, x, 4 * 2 * 2, 3, 1); 31 | geo->insert(1, y, 4 * 2 * 2, 3, 1); 32 | geo->insert(2, z, 4 * 2 * 2, 3, 1); 33 | 34 | auto dims = geo->getDimensions(); 35 | std::cout << dims.size() << " [" << dims[0] << "," << dims[1] << "]" << std::endl; 36 | grid_curv->setGeometry(geo); 37 | grid_collection->insert(grid_curv); 38 | domain->insert(grid_collection); 39 | 40 | auto writer = XdmfWriter::New("test.xdmf"); 41 | domain->accept(writer); 42 | } -------------------------------------------------------------------------------- /src/simpla/algebra/EntityId.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-4-19. 3 | // 4 | #include "EntityId.h" 5 | namespace simpla { 6 | 7 | /** 8 | * Solve problem: Undefined reference to static constexpr char[] 9 | * http://stackoverflow.com/questions/22172789/passing-a-static-constexpr-variable-by-universal-reference 10 | */ 11 | // 12 | constexpr int EntityIdCoder::ndims; 13 | constexpr int EntityIdCoder::MESH_RESOLUTION; 14 | constexpr Real EntityIdCoder::_R; 15 | constexpr EntityId EntityIdCoder::_DK; 16 | constexpr EntityId EntityIdCoder::_DJ; 17 | constexpr EntityId EntityIdCoder::_DI; 18 | constexpr EntityId EntityIdCoder::_DA; 19 | constexpr int EntityIdCoder::m_id_to_index_[]; 20 | constexpr int EntityIdCoder::m_id_to_iform_[]; 21 | constexpr int EntityIdCoder::m_id_to_num_of_ele_in_cell_[]; 22 | constexpr int EntityIdCoder::m_adjacent_cell_num_[4][8]; 23 | constexpr int EntityIdCoder::m_iform_to_num_of_ele_in_cell_[]; 24 | constexpr EntityId EntityIdCoder::m_num_to_id_[]; 25 | constexpr EntityId EntityIdCoder::m_id_to_shift_[]; 26 | constexpr int EntityIdCoder::m_id_to_sub_index_[]; 27 | constexpr int EntityIdCoder::m_sub_index_to_id_[4][3]; 28 | constexpr EntityId EntityIdCoder::m_adjacent_cell_matrix_[4 /* to GetIFORM*/][NUM_OF_NODE_ID /* node id*/] 29 | [MAX_NUM_OF_ADJACENT_CELL /*id shift*/]; 30 | constexpr Real EntityIdCoder::m_id_to_coordinates_shift_[8][3]; 31 | } -------------------------------------------------------------------------------- /src/simpla/data/DataFunction.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-8-25. 3 | // 4 | 5 | #ifndef SIMPLA_DATAFUNCTION_H 6 | #define SIMPLA_DATAFUNCTION_H 7 | 8 | #include "DataEntity.h" 9 | #include "DataUtilities.h" 10 | namespace simpla { 11 | namespace data { 12 | struct DataFunction : public DataEntity { 13 | SP_DEFINE_FANCY_TYPE_NAME(DataFunction, DataEntity) 14 | protected: 15 | DataFunction() = default; 16 | 17 | public: 18 | ~DataFunction() = default; 19 | template 20 | static std::shared_ptr New(Args&&... args) { 21 | return std::shared_ptr(new DataFunction(std::forward(args)...)); 22 | } 23 | 24 | std::ostream& Print(std::ostream& os, int indent) const override { 25 | os << ""; 26 | return os; 27 | } 28 | 29 | virtual std::shared_ptr eval(std::initializer_list> const& args) const { 30 | return DataEntity::New(); 31 | }; 32 | template 33 | U as(Args&&... args) { 34 | return data_cast(eval({make_data(std::forward(args))...})); 35 | }; 36 | template 37 | std::shared_ptr operator()(Args&&... args) const { 38 | return eval({make_data(std::forward(args))...}); 39 | } 40 | }; 41 | } // namespace data 42 | } // namespace simpla 43 | #endif // SIMPLA_DATAFUNCTION_H 44 | -------------------------------------------------------------------------------- /src/simpla/application/SPInit.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-9-4. 3 | // 4 | #include 5 | #include 6 | #include 7 | #include "simpla/parallel/MPIComm.h" 8 | #include "simpla/parallel/Parallel.h" 9 | #include "simpla/utilities/Log.h" 10 | namespace simpla { 11 | int Initialize(int argc, char **argv) { 12 | #ifndef NDEBUG 13 | logger::set_stdout_level(1000); 14 | #endif 15 | 16 | std::string geo_engine; 17 | simpla::parse_cmd_line( // 18 | argc, argv, [&](std::string const &opt, std::string const &value) -> int { 19 | if (false) { 20 | } else if (opt == "v") { 21 | logger::set_stdout_level(static_cast(std::atoi(value.c_str()))); 22 | } else if (opt == "geo_engine") { 23 | geo_engine = value; 24 | } 25 | return CONTINUE; 26 | }); 27 | 28 | parallel::Initialize(argc, argv); 29 | geometry::Initialize(geo_engine); 30 | 31 | GLOBAL_COMM.barrier(); 32 | MESSAGE << std::endl << ShowLogo() << std::endl; 33 | GLOBAL_COMM.barrier(); 34 | return SP_SUCCESS; 35 | } 36 | int Finalize() { 37 | geometry::Finalize(); 38 | GLOBAL_COMM.barrier(); 39 | MESSAGE << std::endl << "======== DONE ========" << std::endl; 40 | GLOBAL_COMM.barrier(); 41 | parallel::Finalize(); 42 | return SP_SUCCESS; 43 | } 44 | } // namespace simpla -------------------------------------------------------------------------------- /src/simpla/geometry/gCone.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-23. 3 | // 4 | 5 | #ifndef SIMPLA_GCONE_H 6 | #define SIMPLA_GCONE_H 7 | 8 | #include 9 | #include 10 | #include "gBody.h" 11 | #include "gCurve.h" 12 | #include "gSurface.h" 13 | namespace simpla { 14 | namespace geometry { 15 | 16 | struct gConic : public gCurve2D { 17 | SP_GEO_ENTITY_ABS_HEAD(gCurve2D, gConic) 18 | }; 19 | struct gCone : public gBody { 20 | SP_GEO_ENTITY_HEAD(gBody, gCone, Cone) 21 | explicit gCone(Real angle, Real radius) : m_Angle_(angle), m_Radius_(radius) {} 22 | point_type xyz(Real l, Real phi, Real theta) const override { 23 | Real r = l * std::sin(theta); 24 | return point_type{r * std::cos(phi), r * std::sin(phi), l * std::cos(theta)}; 25 | } 26 | SP_PROPERTY(Real, Angle); 27 | SP_PROPERTY(Real, Radius) = 1.0; 28 | }; 29 | 30 | struct gConicSurface : public gSurface { 31 | SP_GEO_ENTITY_ABS_HEAD(gSurface, gConicSurface) 32 | explicit gConicSurface(Real angle, Real radius) : m_Angle_(angle), m_Radius_(radius) {} 33 | point_type xyz(Real l, Real phi) const override { 34 | Real r = l * std::sin(m_Angle_); 35 | return point_type{r * std::cos(phi), r * std::sin(phi), l * std::cos(m_Angle_)}; 36 | } 37 | SP_PROPERTY(Real, Angle); 38 | SP_PROPERTY(Real, Radius) = 1.0; 39 | }; 40 | } // namespace geometry 41 | } // namespace simpla 42 | #endif // SIMPLA_GCONE_H 43 | -------------------------------------------------------------------------------- /src/simpla/geometry/gSweeping.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-11-22. 3 | // 4 | 5 | #ifndef SIMPLA_GSWEEPING_H 6 | #define SIMPLA_GSWEEPING_H 7 | 8 | #include "Axis.h" 9 | #include "GeoEntity.h" 10 | #include "gBody.h" 11 | #include "gCurve.h" 12 | #include "gSurface.h" 13 | 14 | namespace simpla { 15 | namespace geometry { 16 | 17 | struct gSweeping : public GeoEntity { 18 | SP_GEO_ENTITY_HEAD(GeoEntity, gSweeping, Sweeping); 19 | 20 | explicit gSweeping(std::shared_ptr const& basis_entity, std::shared_ptr const& curve, 21 | Axis const& r_axis = Axis{}); 22 | gSweeping(gSweeping const&); 23 | 24 | void Deserialize(std::shared_ptr const& cfg) override; 25 | std::shared_ptr Serialize() const override; 26 | 27 | void SetRelativeAxis(Axis const&); 28 | Axis const& GetRelativeAxis() const; 29 | void SetPath(std::shared_ptr const&); 30 | std::shared_ptr GetPath() const; 31 | void SetBasis(std::shared_ptr const&); 32 | std::shared_ptr GetBasis() const; 33 | 34 | point_type xyz(Real u, Real v, Real w) const override; 35 | 36 | private: 37 | std::shared_ptr m_path_; 38 | std::shared_ptr m_basis_; 39 | Axis m_r_axis_; 40 | }; 41 | 42 | } // namespace geometry { 43 | } // namespace simpla { 44 | #endif // SIMPLA_GSWEEPING_H 45 | -------------------------------------------------------------------------------- /test/algebra/array_dummy.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 16-12-28. 3 | // 4 | 5 | #include 6 | #include "simpla/algebra/Array.h" 7 | #include "simpla/algebra/ExpressionTemplate.h" 8 | #include "simpla/algebra/nTuple.ext.h" 9 | #include "simpla/algebra/nTuple.h" 10 | 11 | using namespace simpla; 12 | 13 | int main(int argc, char **argv) { 14 | index_box_type inner_box{{0, 0, 0}, {5, 4, 1}}; 15 | Array a(inner_box); 16 | Array b(inner_box); 17 | Array c(inner_box); 18 | Array d(inner_box); 19 | 20 | a = [](index_type i, index_type j, index_type k) { return static_cast(i + j + k); }; 21 | 22 | b = [](index_type i, index_type j, index_type k) { return static_cast(j * i); }; 23 | 24 | std::cout << " a = " << a << std::endl; 25 | std::cout << " b = " << b << std::endl; 26 | 27 | c = a + b * 2; 28 | std::cout << " c = " << c << std::endl; 29 | // 30 | // std::cout << " d = " << c << std::endl; 31 | // FE_CMD(c = a + sin(b) * 3 + d); 32 | 33 | // FE_CMD(c = a + sin(b) * 3 + d); 34 | // c = a(IdxShift{0, 1, 0}) - a(IdxShift{0, -1, 0}) + a(IdxShift{0, 0, 1}) - a(IdxShift{0, 0, -1}); 35 | // // nTuple v = {1, 2, 3}; 36 | // // Array, 3> e(inner_box); 37 | // // e = b * v; 38 | // std::cout << a << std::endl; 39 | // std::cout << c << std::endl; 40 | 41 | std::cout << "DONE" << std::endl; 42 | } -------------------------------------------------------------------------------- /src/simpla/geometry/gEllipse.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-22. 3 | // 4 | 5 | #ifndef SIMPLA_GELLIPSE_H 6 | #define SIMPLA_GELLIPSE_H 7 | 8 | #include 9 | #include "gCone.h" 10 | #include "gPlane.h" 11 | #include "gSurface.h" 12 | namespace simpla { 13 | namespace geometry { 14 | struct gEllipse : public gConic { 15 | SP_GEO_ENTITY_HEAD(GeoEntity, gEllipse, Ellipse); 16 | 17 | explicit gEllipse(Real major_radius, Real minor_radius) 18 | : m_MajorRadius_(major_radius), m_MinorRadius_(minor_radius) {} 19 | 20 | bool IsClosed() const override { return true; } 21 | 22 | SP_PROPERTY(Real, MajorRadius) = 1.0; 23 | SP_PROPERTY(Real, MinorRadius) = 0.5; 24 | point2d_type xy(Real alpha) const override { 25 | return point2d_type{m_MajorRadius_ * std::cos((alpha)), m_MinorRadius_ * std::sin((alpha))}; 26 | }; 27 | }; 28 | 29 | struct gEllipseDisk : public gPlane { 30 | SP_GEO_ENTITY_HEAD(gPlane, gEllipseDisk, EllipseDisk); 31 | 32 | explicit gEllipseDisk(Real major_radius, Real minor_radius) 33 | : m_MinorRadius_(minor_radius), m_MajorRadius_(major_radius) {} 34 | SP_PROPERTY(Real, MajorRadius); 35 | SP_PROPERTY(Real, MinorRadius); 36 | 37 | point2d_type xy(Real r, Real alpha) const override { 38 | return point2d_type{r * std::cos(alpha), r * m_MinorRadius_ / m_MajorRadius_ * std::sin(alpha)}; 39 | }; 40 | }; 41 | } // namespace geometry{ 42 | } // namespace simpla{ 43 | #endif // SIMPLA_GELLIPSE_H 44 | -------------------------------------------------------------------------------- /src/simpla/geometry/gTorus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-10-24. 3 | // 4 | 5 | #ifndef SIMPLA_GTORUS_H 6 | #define SIMPLA_GTORUS_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "gBody.h" 14 | 15 | namespace simpla { 16 | namespace geometry { 17 | struct gTorus : public gBody { 18 | SP_GEO_ENTITY_HEAD(gBody, gTorus, Torus) 19 | 20 | explicit gTorus(Real major_radius, Real minor_radius, Real min_major_angle = 0, Real max_major_angle = TWOPI, 21 | Real min_minor_angle = 0, Real max_minor_angle = TWOPI) 22 | : m_MinorRadius_(minor_radius), 23 | m_MajorRadius_(major_radius), 24 | m_MinMajorAngle_(min_major_angle), 25 | m_MaxMajorAngle_(max_major_angle), 26 | m_MinMinorAngle_(min_minor_angle), 27 | m_MaxMinorAngle_(max_minor_angle) {} 28 | 29 | SP_PROPERTY(Real, MajorRadius); 30 | SP_PROPERTY(Real, MinorRadius); 31 | SP_PROPERTY(Real, MaxMajorAngle); 32 | SP_PROPERTY(Real, MinMajorAngle); 33 | SP_PROPERTY(Real, MinMinorAngle); 34 | SP_PROPERTY(Real, MaxMinorAngle); 35 | point_type xyz(Real r, Real theta, Real phi) const override { 36 | Real R = (m_MajorRadius_ + r * std::cos(theta)); 37 | return point_type{R * std::cos(phi), R * std::sin(phi), r * std::sin(theta)}; 38 | }; 39 | }; 40 | 41 | } // namespace geometry 42 | } // namespace simpla 43 | #endif // SIMPLA_GTORUS_H 44 | -------------------------------------------------------------------------------- /CMake/FindPython.cmake: -------------------------------------------------------------------------------- 1 | #- Find Python 2 | # INPUT: 3 | # PYTHONHOME 4 | # PYTHONPATH 5 | # This module will define the following variable: 6 | # OUTPUT: 7 | # PYTHON_VERSION 8 | # PYTHON_FOUND 9 | # PYTHON_INCLUDE_DIRS 10 | # PYTHON_LIBRARIES 11 | 12 | if( PYTHON_EXECUTABLE ) 13 | #DO NOTHING 14 | else() 15 | 16 | FOREACH(_CURRENT_VERSION 2.7 2.6 2.5 2.4) 17 | find_program(PYTHON_EXECUTABLE 18 | NAME python${_CURRENT_VERSION}${CMAKE_EXECUTABLE_SUFFIX} 19 | HINTS $ENV{PYTHONHOME}/bin 20 | ) 21 | find_library(PYTHON_LIBRARIES 22 | NAME ${CMAKE_SHARED_LIBRARY_PREFIX}python${_CURRENT_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX} 23 | HINTS $ENV{PYTHONHOME}/lib 24 | ) 25 | 26 | find_path(PYTHON_INCLUDE_DIRS 27 | NAMES Python.h 28 | HINTS $ENV{PYTHONHOME}/include 29 | PATH_SUFFIXES python${_CURRENT_VERSION} 30 | ) 31 | 32 | if( (${PYTHON_LIBRARIES} STREQUAL "PYTHON_LIBRARIES-NOTFOUND") 33 | OR 34 | ( ${PYTHON_INCLUDE_DIRS} STREQUAL "PYTHON_INCLUDE_DIRS-NOTFOUND") 35 | OR 36 | (${PYTHON_EXECUTABLE} STREQUAL "PYTHON_EXECUTABLE-NOTFOUND") 37 | ) 38 | #DO NOTHING 39 | else() 40 | set(PYTHON_VERSION "${_CURRENT_VERSION}") 41 | break() 42 | endif() 43 | ENDFOREACH() 44 | 45 | endif() 46 | 47 | INCLUDE(FindPackageHandleStandardArgs) 48 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python DEFAULT_MSG PYTHON_EXECUTABLE ) 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, YU Zhi 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the GetName of SIMPla nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/simpla/parallel/ParallelTbb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file parallel_tbb.h 3 | * 4 | * Created on: 2014-9-4 5 | * Author: salmon 6 | */ 7 | 8 | #ifndef PARALLEL_TBB_H_ 9 | #define PARALLEL_TBB_H_ 10 | 11 | //#define TBB_IMPLEMENT_CPP0X true 12 | 13 | #include 13 | #include 14 | #include 15 | #include 16 | #include "type_traits.h" 17 | #include "MPIComm.h" 18 | #include "MPIUpdate.h" 19 | 20 | namespace simpla { namespace parallel 21 | { 22 | 23 | struct DistributedCounter 24 | { 25 | 26 | std::atomic m_start_, m_end_; 27 | 28 | public: 29 | 30 | DistributedCounter() : m_start_(0), m_end_(0) {} 31 | 32 | virtual ~DistributedCounter() {} 33 | 34 | DistributedCounter(DistributedCounter const &other) = delete; 35 | 36 | /** 37 | * // thread safe 38 | * @param pic number of sample point 39 | * @param volume volume of sample region 40 | * @param box shape of spatial sample region (e.g. box(x_min,x_max)) 41 | * @param args... other of args for v_dist 42 | */ 43 | size_t get(size_t num) { return (m_start_ += num) - num; }; 44 | 45 | 46 | void reserve(size_t num) 47 | { 48 | ASSERT(m_start_.load() == 0); 49 | 50 | int offset = 0; 51 | int total = 0; 52 | std::tie(m_start_, std::ignore) = 53 | parallel::sync_global_location(GLOBAL_COMM, static_cast(num )); 54 | m_start_ = offset; 55 | m_end_ = offset + num; 56 | 57 | } 58 | 59 | }; 60 | 61 | }} 62 | #endif //SIMPLA_DISTRIBUTEDCOUNTER_H 63 | -------------------------------------------------------------------------------- /src/simpla/predefine/device/ICRFAntenna.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-6-5. 3 | // 4 | 5 | #ifndef SIMPLA_ICRFANTENNA_H 6 | #define SIMPLA_ICRFANTENNA_H 7 | 8 | #include "simpla/SIMPLA_config.h" 9 | 10 | #include 11 | #include 12 | 13 | #include "simpla/algebra/Algebra.h" 14 | #include "simpla/data/DataEntry.h" 15 | #include "simpla/engine/Engine.h" 16 | #include "simpla/physics/Field.h" 17 | #include "simpla/physics/PhysicalConstants.h" 18 | 19 | namespace simpla { 20 | 21 | using namespace data; 22 | 23 | template 24 | class ICRFAntenna : public TDomain { 25 | SP_DOMAIN_HEAD(ICRFAntenna, TDomain); 26 | 27 | Field J{this, "name"_ = "J"}; 28 | 29 | SP_PROPERTY(Vec3, Amplify) = {1, 0, 0}; 30 | SP_PROPERTY(Real, Frequency) = 1.0; 31 | SP_PROPERTY(Vec3, WaveNumber) = {1, 0, 0}; 32 | }; 33 | 34 | template 35 | void ICRFAntenna::DoInitialCondition(Real time_now) { 36 | // m_domain_->GetMesh()->SetEmbeddedBoundary(m_domain_->GetName(), m_domain_->GetGeoBody()); 37 | } 38 | 39 | template 40 | void ICRFAntenna::DoAdvance(Real time_now, Real dt) { 41 | DEFINE_PHYSICAL_CONST 42 | 43 | SP_CMD((J = [=](point_type const& x) -> nTuple { 44 | nTuple res = m_Amplify_ * std::sin(m_WaveNumber_[0] * x[0] + m_WaveNumber_[1] * x[1] + 45 | m_WaveNumber_[2] * x[2] + TWOPI * m_Frequency_ * time_now); 46 | return res; 47 | })); 48 | } 49 | 50 | } // namespace simpla; 51 | #endif // SIMPLA_ICRFANTENNA_H 52 | -------------------------------------------------------------------------------- /test/engine/policies_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by salmon on 17-7-10. 3 | // 4 | 5 | #include 6 | #include 7 | 8 | template 9 | struct Foo { 10 | T* m_host_; 11 | Foo(T* host) : m_host_(host) { host->Register(this); } 12 | 13 | std::string GetName() { return "I'm the Foo"; } 14 | }; 15 | 16 | template 17 | class FirstPolicy { 18 | THost* m_self_; 19 | 20 | public: 21 | explicit FirstPolicy(THost* host) : m_self_(host) {} 22 | virtual ~FirstPolicy() = default; 23 | 24 | template 25 | bool Register(TOther* h) { 26 | std::cout << "Register:" << h->GetName() << std::endl; 27 | return true; 28 | } 29 | std::string GetName() { return "I'm the first"; } 30 | }; 31 | 32 | template 33 | class SecondPolicy { 34 | THost* m_self_; 35 | bool m_is_register_; 36 | 37 | public: 38 | SecondPolicy(THost* host) : m_self_(host), m_is_register_(m_self_->Register(this)) {} 39 | virtual ~SecondPolicy() = default; 40 | 41 | std::string GetName() { return "I'm the m_node_"; } 42 | 43 | Foo foo{m_self_}; 44 | }; 45 | 46 | template