Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Rettenberger committed Jul 6, 2017
0 parents commit b1661b8
Show file tree
Hide file tree
Showing 30 changed files with 3,935 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# KDevelop4
*.kdev4
*.kdev4/

# SCons
build/
config.log
.sconsign.dblite
.sconf_temp/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "submodules/scons-tools"]
path = submodules/scons-tools
url = https://github.com/TUM-I5/scons-tools.git
[submodule "submodules/utils"]
path = submodules/utils
url = https://github.com/TUM-I5/utils.git
28 changes: 28 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2017, Technical University of Munich
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
154 changes: 154 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#! /usr/bin/python

# @file
# This file is part of PUMGen
#
# For conditions of distribution and use, please see the copyright
# notice in the file 'COPYING' at the root directory of this package
# and the copyright notice at https://github.com/SeisSol/PUMGen
#
# @copyright 2017 Technical University of Munich
# @author Sebastian Rettenberger <[email protected]>
#

import os
import sys

import libs
import utils.compiler
import utils.variables

# set possible variables
vars = utils.variables.Variables()

# Add build type
vars.AddBuildType()

# Add prefix path
vars.AddPrefixPathVariable()

# Add compiler variables
vars.AddCompilerVariable()

# PUMGen specific variables
vars.AddVariables(
PathVariable( 'buildDir', 'where to build the code', 'build', PathVariable.PathIsDirCreate ),

EnumVariable( 'logLevel',
'logging level. \'debug\' prints all information available, \'info\' prints information at runtime (time step, plot number), \'warning\' prints warnings during runtime, \'error\' is most basic and prints errors only',
'info',
allowed_values=('debug', 'info', 'warning', 'error')
),

BoolVariable( 'netcdf', 'compile netCDF support (required to read old SeisSol meshes)',
False,
),

BoolVariable( 'simModSuite', 'compile with support for simModSuite from Simmetrix',
False
),

( 'mpiLib', 'MPI library against this is linked (only required for simModSuite)',
'mpich2',
None, None
),

PathVariable( 'cc',
'C compiler (default: mpicc)',
None,
PathVariable.PathAccept
),

PathVariable( 'cxx',
'C++ compiler (default: mpicxx)',
None,
PathVariable.PathAccept
),

BoolVariable( 'useEnv',
'set variables set in the execution environment',
True
)
)

vars.ParseVariableFile()

# Create the environment
env = Environment(variables=vars)

# generate help text
vars.SetHelpText(env)

# Check for any unknown (maybe misspelled) variables
vars.CheckUnknownVariables(env)

# Set environment
if env['useEnv']:
env['ENV'] = os.environ

#
# precompiler, compiler and linker flags
#

# Set compiler
env['CC'] = 'mpicc'
env['CXX'] = 'mpicxx'
vars.SetCompiler(env)

# set level of logger
if env['logLevel'] == 'debug':
env.Append(CPPDEFINES=['LOG_LEVEL=3'])
elif env['logLevel'] == 'info':
env.Append(CPPDEFINES=['LOG_LEVEL=2'])
elif env['logLevel'] == 'warning':
env.Append(CPPDEFINES=['LOG_LEVEL=1'])
elif env['logLevel'] == 'error':
env.Append(CPPDEFINES=['LOG_LEVEL=0'])
else:
assert(false)

# compiler flags for generated kernels
env.Append(CXXFLAGS = ['-Wall', '-ansi', '-std=c++0x'])
if utils.compiler.optimizationEnabled(env):
env.Append(CPPDEFINES=['NDEBUG'])
env.Append(CXXFLAGS=['-O2'])
else:
env.Append(CXXFLAGS=['-O0'])
if utils.compiler.debugEnabled(env):
env.Append(CXXFLAGS=['-g'])

# add pathname to the list of directories which are search for include
env.Append(CPPPATH=['#/src'])

# Enable openmp
env.Append(CXXFLAGS = ['-fopenmp'])
env.Append(LINKFLAGS= ['-fopenmp'])

# Set prefix pathes for libraries
vars.SetPrefixPathes(env)

# utils library
env.Append(CPPPATH=['#/submodules'])

# APF (one of the Zoltan functions is required)
libs.find(env, 'apf', simmetrix=env['simModSuite'], zoltan=True)

# netCDF
env['use_netcdf'] = libs.find(env, 'netcdf', required=env['netcdf'], parallel=True)
if env['use_netcdf']:
env.Append(CPPDEFINES=['USE_NETCDF'])

# SimModSuite
env['use_simmodsuite'] = libs.find(env, 'simmodsuite', required=env['simModSuite'], mpiLib=env['mpiLib'])
if env['use_simmodsuite']:
env.Append(CPPDEFINES=['USE_SIMMOD'])

# get the source files
env.sourceFiles = []

Export('env')
SConscript('src/SConscript', variant_dir='#/'+env['buildDir']+'/src', src_dir='#/src', duplicate=0)
Import('env')

# build tools
env.Program('#/'+env['buildDir']+'/pumgen', env.sourceFiles)
1 change: 1 addition & 0 deletions site_scons/libs
1 change: 1 addition & 0 deletions site_scons/utils
23 changes: 23 additions & 0 deletions src/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /usr/bin/python

# @file
# This file is part of PUMGen
#
# For conditions of distribution and use, please see the copyright
# notice in the file 'COPYING' at the root directory of this package
# and the copyright notice at https://github.com/SeisSol/PUMGen
#
# @copyright 2017 Technical University of Munich
# @author Sebastian Rettenberger <[email protected]>
#

Import('env')

env.sourceFiles = [env.Object('pumgen.cpp')]

for dir in ['input', 'meshreader']:
Export('env')
SConscript(dir+'/SConscript', variant_dir='#/'+env['buildDir']+'/src/'+dir, src_dir='#/src/'+dir, duplicate=0)
Import('env')

Export('env')
39 changes: 39 additions & 0 deletions src/input/ApfNative.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @file
* This file is part of PUMGen
*
* For conditions of distribution and use, please see the copyright
* notice in the file 'COPYING' at the root directory of this package
* and the copyright notice at https://github.com/SeisSol/PUMGen
*
* @copyright 2017 Technical University of Munich
* @author Sebastian Rettenberger <[email protected]>
*/

#ifndef APF_NATIVE_H
#define APF_NATIVE_H

#include <apfMDS.h>
#include <gmi_mesh.h>
#include <gmi_null.h>

#include "utils/logger.h"

#include "MeshInput.h"

class ApfNative : public MeshInput
{
public:
ApfNative(const char* mesh, const char* model = 0L)
{
if (model)
gmi_register_mesh();
else {
gmi_register_null();
model = ".null";
}
m_mesh = apf::loadMdsMesh(model, mesh);
}
};

#endif // APF_NATIVE_H
35 changes: 35 additions & 0 deletions src/input/MeshInput.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @file
* This file is part of PUMGen
*
* For conditions of distribution and use, please see the copyright
* notice in the file 'COPYING' at the root directory of this package
* and the copyright notice at https://github.com/SeisSol/PUMGen
*
* @copyright 2017 Technical University of Munich
* @author Sebastian Rettenberger <[email protected]>
*/

#include <apfMesh2.h>

#ifndef MESH_INTPUT_H
#define MESH_INTPUT_H

/**
* Interface for mesh input
*/
class MeshInput
{
protected:
apf::Mesh2* m_mesh;

public:
virtual ~MeshInput() {}

apf::Mesh2* getMesh()
{
return m_mesh;
}
};

#endif // MESH_INPUT_H
Loading

0 comments on commit b1661b8

Please sign in to comment.