Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
github-classroom[bot] authored Feb 25, 2024
0 parents commit c5609b7
Show file tree
Hide file tree
Showing 16 changed files with 765 additions and 0 deletions.
177 changes: 177 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#
# The clang-format (Clang 6) style file used by deal.II.
#

AccessModifierOffset: -2

AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true

AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false

AlwaysBreakAfterReturnType: All
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true

BinPackArguments: false
BinPackParameters: false

BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: true
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false

BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: false

ColumnLimit: 80

CompactNamespaces: false

ConstructorInitializerIndentWidth: 2

ContinuationIndentWidth: 2

Cpp11BracedListStyle: true

DerivePointerAlignment: false

FixNamespaceComments: true

IncludeBlocks: Regroup
IncludeCategories:
# config.h must always be first:
- Regex: "deal.II/base/config.h"
Priority: -1
# deal.II folders in sorted order:
- Regex: "deal.II/algorithms/.*\\.h"
Priority: 110
- Regex: "deal.II/base/.*\\.h"
Priority: 120
- Regex: "deal.II/boost_adaptors/.*\\.h"
Priority: 125
- Regex: "deal.II/differentiation/.*\\.h"
Priority: 130
- Regex: "deal.II/distributed/.*\\.h"
Priority: 140
- Regex: "deal.II/dofs/.*\\.h"
Priority: 150
- Regex: "deal.II/fe/.*\\.h"
Priority: 160
- Regex: "deal.II/gmsh/.*\\.h"
Priority: 170
- Regex: "deal.II/grid/.*\\.h"
Priority: 180
- Regex: "deal.II/hp/.*\\.h"
Priority: 190
- Regex: "deal.II/integrators/.*\\.h"
Priority: 200
- Regex: "deal.II/lac/.*\\.h"
Priority: 210
- Regex: "deal.II/matrix_free/.*\\.h"
Priority: 220
- Regex: "deal.II/meshworker/.*\\.h"
Priority: 230
- Regex: "deal.II/multigrid/.*\\.h"
Priority: 240
- Regex: "deal.II/non_matching/.*\\.h"
Priority: 250
- Regex: "deal.II/numerics/.*\\.h"
Priority: 260
- Regex: "deal.II/opencascade/.*\\.h"
Priority: 270
- Regex: "deal.II/optimization/.*\\.h"
Priority: 280
- Regex: "deal.II/particles/.*\\.h"
Priority: 290
- Regex: "deal.II/physics/.*\\.h"
Priority: 300
- Regex: "deal.II/simplex/.*\\.h"
Priority: 310
- Regex: "deal.II/sundials/.*\\.h"
Priority: 320
# put boost right after deal:
- Regex: "<boost.*>"
Priority: 500
# try to group PETSc headers:
- Regex: "<petsc.*\\.h>"
Priority: 1000
# try to catch all third party headers and put them after deal.II but before
# standard headers:
- Regex: "<.*\\.(h|hpp|hxx)>"
Priority: 2000
# match all standard headers. Things like '#include <armadillo>' should be
# surrounded by #ifdef checks (which will not be merged by clang-format) so they
# should not be caught here
- Regex: "<[a-z_]+>"
Priority: 100000
# make sure that "../tests.h" appears before all other local include files
# such that replacing Assert in tests also applies to the testing header files.
- Regex: "\\.\\./tests\\.h"
Priority: 200000

IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 2

IndentWrappedFunctionNames: false

KeepEmptyLinesAtTheStartOfBlocks: false

Language: Cpp

MaxEmptyLinesToKeep: 3

NamespaceIndentation: All

PenaltyBreakBeforeFirstCallParameter: 90

PointerAlignment: Right

ReflowComments: true
CommentPragmas: '( \| |\*--|<li>|@ref | @p |@param |@name |@returns |@warning |@ingroup |@author |@date |@related |@relates |@relatesalso |@deprecated |@image |@return |@brief |@attention |@copydoc |@addtogroup |@todo |@tparam |@see |@note |@skip |@skipline |@until |@line |@dontinclude |@include)'

SortIncludes: true
SortUsingDeclarations: true

SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

Standard: Cpp11

TabWidth: 2

UseTab: Never
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM heltai/dealii:vscode

LABEL maintainer="[email protected]"

USER $USER

WORKDIR $HOME
51 changes: 51 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.122.1/containers/docker-existing-dockerfile
{
"name": "deal.II master container",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": null
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"davydden.dealii-prm",
"johnpapa.vscode-peacock",
"alefragnani.project-manager",
"ms-vscode.cpptools",
"shan.code-settings-sync",
"ms-vscode.cmake-tools",
"xaver.clang-format",
"ms-azuretools.vscode-docker",
"davidschuldenfrei.gtest-adapter",
"cschleiden.vscode-github-actions"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "sudo apt-get update && sudo apt-get install -y gdb",
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "dealii",
// Make sure we add a BUILD_POSTFIX environment variable that can be used as in
// ${workspaceFolder}/build${env:BUILD_POSTFIX}
"containerEnv": {
"BUILD_POSTFIX": "-container",
},
"mounts": [
"source=vscode-extensions,target=/home/dealii/.vscode-server/extensions,type=volume",
// And/or for VS Code Insiders
"source=vscode-extensions-insiders,target=/home/dealii/.vscode-server-insiders/extensions,type=volume",
],
// Uncomment the following if you want to work on docker on a remote machine
// In this case, you also need "docker.host": "ssh://name-of-machine" in your
// settings.
// "workspaceMount": "source=/home/heltai/codes/sa-pinvit,target=/workspace,type=bind,consistency=cached",
// "workspaceFolder": "/workspace",
}
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: GitHub CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
debug:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build debug
run: |
.scripts/dr.sh "rm -rf build_linux_debug"
.scripts/dr.sh "mkdir build_linux_debug; cd build_linux_debug; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug; ninja"
- name: GTest debug
run: |
.scripts/dr.sh "cd build_linux_debug; ./gtest"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
compile_commands.json
4 changes: 4 additions & 0 deletions .scripts/check_indentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
.scripts/indent
git diff
git diff-files --quiet
7 changes: 7 additions & 0 deletions .scripts/dr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
docker run \
--user $(id -u):$(id -g) \
--rm -t \
-v `pwd`:/builds/app \
heltai/dealii:vscode \
/bin/sh -c "cd /builds/app; $@"
18 changes: 18 additions & 0 deletions .scripts/indent
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if test ! -d .scripts ; then
echo "*** This script must be run from the top-level directory of your project."
exit
fi

if test ! -f .clang-format ; then
echo "*** No style file .clang-format found."
exit
fi

# collect a list of files and then indent them all
echo "--- Indenting all header and source files"
SRC_FILES=`find . -name "*.cc"`
#H_FILES=`find . -name "*.h"`
clang-format -i $SRC_FILES
#clang-format -i $H_FILES
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"cmake.buildDirectory": "${workspaceFolder}/build${env:BUILD_POSTFIX}",
"cmake.defaultVariants": {
"configOptions": {
"default": "dealii-app",
"description": "Default build option for app",
"choices": {
"dealii-app": {
"short": "Build deal.II App",
"long": "Options to build deal.II App",
}
}
}
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"files.associations": {
"*.inst": "cpp",
"*.inst.in": "cpp",
"*.h": "cpp"
}
}
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)

PROJECT(gtest)

FIND_PACKAGE(deal.II 9.3 REQUIRED
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR})

DEAL_II_INITIALIZE_CACHED_VARIABLES()

ADD_EXECUTABLE(step-1 source/step-1.cc)
DEAL_II_SETUP_TARGET(step-1)

ADD_EXECUTABLE(step-2 source/step-2.cc)
DEAL_II_SETUP_TARGET(step-2)

ADD_LIBRARY(step-1-lib SHARED $<TARGET_OBJECTS:step-1>)
DEAL_II_SETUP_TARGET(step-1-lib)

ADD_LIBRARY(step-2-lib SHARED $<TARGET_OBJECTS:step-2>)
DEAL_II_SETUP_TARGET(step-2-lib)

FIND_PACKAGE(GTest)
ADD_EXECUTABLE(gtest source/gtest.cc)
TARGET_LINK_LIBRARIES(gtest ${GTEST_LIBRARY} step-1-lib step-2-lib)
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
DEAL_II_SETUP_TARGET(gtest)

ENABLE_TESTING()
GTEST_DISCOVER_TESTS(gtest)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Theory and Practice of FEM

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit c5609b7

Please sign in to comment.