Commit ab325fe2 authored by Mark Meredith's avatar Mark Meredith
Browse files

Add time

parent 9407d2e8
Loading
Loading
Loading
Loading
Loading

.clang-format

0 → 100644
+137 −0
Original line number Diff line number Diff line
---
Language:        Cpp
# BasedOnStyle:  LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands:   true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
  AfterCaseLabel:  false
  AfterClass:      false
  AfterControlStatement: false
  AfterEnum:       false
  AfterFunction:   false
  AfterNamespace:  false
  AfterObjCDeclaration: false
  AfterStruct:     false
  AfterUnion:      false
  AfterExternBlock: false
  BeforeCatch:     false
  BeforeElse:      false
  IndentBraces:    false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit:     80
CommentPragmas:  '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat:   false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
  - foreach
  - Q_FOREACH
  - BOOST_FOREACH
IncludeBlocks:   Preserve
IncludeCategories:
  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
    Priority:        2
    SortPriority:    0
  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
    Priority:        3
    SortPriority:    0
  - Regex:           '.*'
    Priority:        1
    SortPriority:    0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth:     2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd:   ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments:  true
SortIncludes:    true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles:  false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard:        Latest
StatementMacros:
  - Q_UNUSED
  - QT_REQUIRE_VERSION
TabWidth:        8
UseCRLF:         false
UseTab:          Never
...
+0 −3
Original line number Diff line number Diff line
[submodule "PEGTL"]
	path = subprojects/PEGTL
	url = https://github.com/taocpp/PEGTL
[submodule "mfix/subprojects/mfix"]
	path = subprojects/mfix
	url = ../mfix
[submodule "subprojects/Catch2"]
	path = subprojects/Catch2
	url = https://github.com/catchorg/Catch2

src/geometry.cpp

0 → 100644
+64 −0
Original line number Diff line number Diff line
#include <iostream>

#include "solver.hpp"

namespace solver {

std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) {
  solver::GeometrySettings geo;
  std::string PROB_LO("geometry.prob_lo");
  std::string PROB_HI("geometry.prob_hi");
  std::string PERIODIC("geometry.is_periodic");
  std::string N_CELL("amr.n_cell");
  if (!ii.count(PROB_LO)) {
    require(PROB_LO);
    return std::nullopt;
  }
  if (!ii.count(PROB_HI)) {
    require(PROB_HI);
    return std::nullopt;
  }
  if (!ii.count(PERIODIC)) {
    require(PERIODIC);
    return std::nullopt;
  }
  if (!ii.count(N_CELL)) {
    require(N_CELL);
    return std::nullopt;
  }
  auto lows = std::get<solver::NumberArray>(ii[PROB_LO]);
  auto highs = std::get<solver::NumberArray>(ii[PROB_HI]);
  auto is_periodic = std::get<solver::NumberArray>(ii[PERIODIC]);
  auto n_cell = std::get<solver::NumberArray>(ii[N_CELL]);
  if (lows.size() != 3) {
    std::cout << "prob_lo needs 3 elements " << std::endl;
    return std::nullopt;
  }
  if (highs.size() != 3) {
    std::cout << "prob_hi needs 3 elements " << std::endl;
    return std::nullopt;
  }
  if (is_periodic.size() != 3) {
    std::cout << "periodic needs 3 elements " << std::endl;
    return std::nullopt;
  }
  if (n_cell.size() != 3) {
    std::cout << "n_cell needs 3 elements " << std::endl;
    return std::nullopt;
  }

  std::get<0>(geo.axes).high = highs[0];
  std::get<0>(geo.axes).low = lows[0];
  std::get<0>(geo.axes).periodic = is_periodic[0];
  std::get<0>(geo.axes).n_cell = n_cell[0];
  std::get<1>(geo.axes).high = highs[1];
  std::get<1>(geo.axes).low = lows[1];
  std::get<1>(geo.axes).periodic = is_periodic[1];
  std::get<1>(geo.axes).n_cell = n_cell[1];
  std::get<2>(geo.axes).high = highs[2];
  std::get<2>(geo.axes).low = lows[2];
  std::get<2>(geo.axes).periodic = is_periodic[2];
  std::get<2>(geo.axes).n_cell = n_cell[2];
  return geo;
}
} // namespace solver
+2 −0
Original line number Diff line number Diff line
lib_parser = static_library('mfix-parser',
                            'geometry.cpp',
                            'parser.cpp',
                            'solver.cpp',
                            'time.cpp',
                            include_directories: tao_inc,
                            install : true)

+9 −53
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

#include "solver.hpp"

namespace {
namespace solver {

void require(std::string key) {
  std::cout << "missing required key:  " << key << std::endl;
@@ -12,64 +12,20 @@ void require(std::string key) {

std::optional<solver::SolverSettings> do_make_solver(solver::InputInfo ii) {
  solver::SolverSettings ss;
  std::string PROB_LO("geometry.prob_lo");
  std::string PROB_HI("geometry.prob_hi");
  std::string PERIODIC("geometry.is_periodic");
  std::string N_CELL("amr.n_cell");
  if (!ii.count(PROB_LO)) {
    require(PROB_LO);
    return std::nullopt;
  }
  if (!ii.count(PROB_HI)) {
    require(PROB_HI);
    return std::nullopt;
  }
  if (!ii.count(PERIODIC)) {
    require(PERIODIC);
    return std::nullopt;
  }
  if (!ii.count(N_CELL)) {
    require(N_CELL);
    return std::nullopt;
  }
  auto lows = std::get<solver::NumberArray>(ii[PROB_LO]);
  auto highs = std::get<solver::NumberArray>(ii[PROB_HI]);
  auto is_periodic = std::get<solver::NumberArray>(ii[PERIODIC]);
  auto n_cell = std::get<solver::NumberArray>(ii[N_CELL]);
  if (lows.size() != 3) {
    std::cout << "prob_lo needs 3 elements " << std::endl;
    return std::nullopt;
  }
  if (highs.size() != 3) {
    std::cout << "prob_hi needs 3 elements " << std::endl;
    return std::nullopt;
  }
  if (is_periodic.size() != 3) {
    std::cout << "periodic needs 3 elements " << std::endl;
  auto new_geo = make_geometry(ii);
  if (!new_geo.has_value()) {
    std::cout << "Problem making geometry" << std::endl;
    return std::nullopt;
  }
  if (n_cell.size() != 3) {
    std::cout << "n_cell needs 3 elements " << std::endl;
  auto new_time = make_time(ii);
  if (!new_time.has_value()) {
    std::cout << "Problem making time" << std::endl;
    return std::nullopt;
  }

  std::get<0>(ss.geometry.axes).high = highs[0];
  std::get<0>(ss.geometry.axes).low = lows[0];
  std::get<0>(ss.geometry.axes).periodic = is_periodic[0];
  std::get<0>(ss.geometry.axes).n_cell = n_cell[0];
  std::get<1>(ss.geometry.axes).high = highs[1];
  std::get<1>(ss.geometry.axes).low = lows[1];
  std::get<1>(ss.geometry.axes).periodic = is_periodic[1];
  std::get<1>(ss.geometry.axes).n_cell = n_cell[1];
  std::get<2>(ss.geometry.axes).high = highs[2];
  std::get<2>(ss.geometry.axes).low = lows[2];
  std::get<2>(ss.geometry.axes).periodic = is_periodic[2];
  std::get<2>(ss.geometry.axes).n_cell = n_cell[2];
  ss.geometry = new_geo.value();
  ss.time = new_time.value();
  return ss;
}
} // namespace

namespace solver {

std::optional<solver::SolverSettings> make_solver(solver::InputInfo ii) {
  auto maybe_state = do_make_solver(ii);
Loading