Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
Language: Cpp
BasedOnStyle: LLVM

ColumnLimit: 80
IndentWidth: 4
ContinuationIndentWidth: 4
TabWidth: 4
UseTab: Never

# OpenFOAM-style brace placement.
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false

AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false

# if (...), for (...), while (...), switch (...)
# but:
# forAll(...), not forAll (...)
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: false
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: false
AfterOverloadedOperator: false
AfterPlacementOperator: false

ForEachMacros:
- forAll
- forAllReverse
- forAllIter
- forAllConstIter
- forAllIters
- forAllConstIters

DerivePointerAlignment: false
PointerAlignment: Left
ReferenceAlignment: Left

SortIncludes:
Enabled: false
ReflowComments: Never
FixNamespaceComments: false

BreakBeforeBinaryOperators: NonAssignment
AlignOperands: AlignAfterOperator
...
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ jobs:

runs-on: ubuntu-latest
container:
image: docker.io/openfoam/openfoam10-paraview510
image: microfluidica/openfoam:13
options: --user root
steps:
- name: Checkout AdditiveFOAM
uses: actions/checkout@v2
- name: Build AdditiveFOAM
run: |
. /opt/openfoam10/etc/bashrc
. /opt/openfoam13/etc/bashrc || true
test -n "$WM_PROJECT_DIR"
./Allwmake
- name: Test AdditiveFOAM
run: |
. /opt/openfoam10/etc/bashrc
. /opt/openfoam13/etc/bashrc || true
cp -r tutorials/AMB2018-02-B userCase
cd userCase
# FIXME: use built-in "additiveFoam" smaller case when created
blockMesh
decomposePar
mpirun -n 6 --oversubscribe --allow-run-as-root additiveFoam -parallel
67 changes: 67 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
minimum_pre_commit_version: "3.7.0"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
files: &openfoam_cpp_files '\.(C|H|I|cc|cpp|cxx|hh|hpp|hxx)$'
exclude: &openfoam_excludes '(^|/)(lnInclude|ThirdParty|platforms|build|processor[0-9]+|postProcessing)/'

- id: end-of-file-fixer
files: *openfoam_cpp_files
exclude: *openfoam_excludes

- id: mixed-line-ending
args: [--fix=lf]
files: *openfoam_cpp_files
exclude: *openfoam_excludes

- id: check-merge-conflict

- id: check-yaml

- repo: local
hooks:
- id: openfoam-no-tabs
name: "OpenFOAM style: no tabs"
language: pygrep
entry: '\t'
files: *openfoam_cpp_files
exclude: *openfoam_excludes

# Manual for now because fixing long C++ lines usually requires judgment.
# Remove "stages: [manual]" once the existing codebase is clean.
- id: openfoam-max-80-columns
name: "OpenFOAM style: max 80 characters"
language: pygrep
entry: '^.{81,}$'
files: *openfoam_cpp_files
exclude: *openfoam_excludes
stages: [manual]

- id: openfoam-space-after-control-keyword
name: "OpenFOAM style: use if (...), for (...), while (...), switch (...)"
language: pygrep
entry: '^(?!\s*#).*\b(if|for|while|switch)\('
files: *openfoam_cpp_files
exclude: *openfoam_excludes

- id: openfoam-forall-no-space
name: "OpenFOAM style: use forAll(...), not forAll (...)"
language: pygrep
entry: '\b(forAll|forAllReverse|forAllIter|forAllConstIter|forAllIters|forAllConstIters)\s+\('
files: *openfoam_cpp_files
exclude: *openfoam_excludes

# Manual only: clang-format is useful as a helper, but it cannot exactly
# represent OpenFOAM stream/math/operator spacing conventions.
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.5
hooks:
- id: clang-format
name: "clang-format: approximate OpenFOAM style, requires manual changes"
args: [--style=file]
files: *openfoam_cpp_files
exclude: *openfoam_excludes
stages: [manual]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The documentation for `AdditiveFOAM` is hosted on [GitHub Pages](https://ornl.gi
| [tutorials](tutorials) | Tutorial cases |

## Installation and Dependencies
[![OpenFOAM-10](https://img.shields.io/badge/OpenFOAM-10-blue.svg)](https://github.com/OpenFOAM/OpenFOAM-10)
[![OpenFOAM-13](https://img.shields.io/badge/OpenFOAM-13-blue.svg)](https://github.com/OpenFOAM/OpenFOAM-13)

AdditiveFOAM is built on source code released by the OpenFOAM Foundation [openfoam.org](https://openfoam.org/), which is available in public [OpenFOAM repositories](https://github.com/OpenFOAM).

Expand Down
1 change: 1 addition & 0 deletions applications/solvers/additiveFoam/Allwmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export ADDITIVEFOAM_BUILD_FLAGS="-DGIT_MODULE_ENABLED=1"
#------------------------------------------------------------------------------
# Build libraries and solver
wmake $targetType functionObjects
wmake $targetType utilities
wmake $targetType movingHeatSource
wmake $targetType

Expand Down
3 changes: 3 additions & 0 deletions applications/solvers/additiveFoam/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ EXE_INC = \
$(ADDITIVEFOAM_BUILD_FLAGS) \
-I. \
-ImovingHeatSource/lnInclude \
-Iutilities/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/randomProcesses/lnInclude

EXE_LIBS = \
-L$(FOAM_USER_LIBBIN) \
-lmovingBeamModels \
-ladditiveFoamUtilities \
-lfiniteVolume \
-lmeshTools \
-lrandomProcesses
70 changes: 50 additions & 20 deletions applications/solvers/additiveFoam/additiveFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 Oak Ridge National Laboratory
Copyright (C) 2023 Oak Ridge National Laboratory
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
Expand All @@ -29,34 +29,57 @@ Application
Description
A transient heat transfer and fluid flow solver for additive manufacturing
simulations.

\*---------------------------------------------------------------------------*/
#include "additiveFoamInfo.H"
#include "fvCFD.H"

#include "argList.H"
#include "timeSelector.H"
#include "zeroGradientFvPatchFields.H"
#include "IFstream.H"
#include "uniformDimensionedFields.H"
#include "pressureReference.H"
#include "findRefCell.H"

#include "fvmDiv.H"
#include "fvmDdt.H"
#include "fvcSurfaceIntegrate.H"
#include "fvcVolumeIntegrate.H"
#include "fvmLaplacian.H"
#include "constrainPressure.H"
#include "constrainHbyA.H"
#include "adjustPhi.H"
#include "pimpleControl.H"
#include "graph.H"
#include "fvCorrectPhi.H"
#include "Polynomial.H"
#include "interpolateXY/interpolateXY.H"
#include "movingHeatSourceModel.H"

#include "EulerDdtScheme.H"
#include "CrankNicolsonDdtScheme.H"

#include "additiveFoamInfo.H"
#include "movingHeatSourceModel.H"
#include "graph.H"
#include "interpolateXY.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#include "postProcess.H"
{
using namespace Foam;

#include "postProcess.H"
#include "setRootCase.H"

AdditiveFoamInfo::write();

#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createDyMControls.H"
#include "createFields.H"
#include "createTimeControls.H"
#include "initContinuityErrs.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Initialize time-stepping controls
scalar DiNum = 0.0;
scalar alphaCoNum = 0.0;
movingHeatSourceModel sources(mesh);
Expand All @@ -67,26 +90,33 @@ int main(int argc, char *argv[])
{
#include "updateProperties.H"

#include "readTimeControls.H"
#include "readDyMControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"

sources.update();


mesh.update();

runTime++;

Info<< "Time = " << runTime.timeName() << nl << endl;
Info<< "Time = " << runTime.name() << nl << endl;

#include "solutionControls.H"
while (pimple.loop() && fluidInDomain)

while (pimple.loop())
{
#include "pU/UEqn.H"
#include "pU/pEqn.H"
#include "moveMesh.H"

if (fluidInDomain)
{
#include "pU/UEqn.H"
#include "pU/pEqn.H"
}
}

#include "thermo/TEqn.H"

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
Expand Down
5 changes: 2 additions & 3 deletions applications/solvers/additiveFoam/additiveFoamInfo.H
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------*\
-------------------------------------------------------------------------------
Copyright (C) 2023 Oak Ridge National Laboratory
Copyright (C) 2023 Oak Ridge National Laboratory
-------------------------------------------------------------------------------

Class
Expand All @@ -21,7 +21,7 @@ Description
#endif

// Static version
#define ADDITIVEFOAM_VERSION "1.2.0-dev"
#define ADDITIVEFOAM_VERSION "2.0.0-dev"

namespace Foam
{
Expand Down Expand Up @@ -60,4 +60,3 @@ public:
#endif

// ************************************************************************* //

Loading
Loading