Skip to content

Commit

Permalink
MERGING DEVELOPMENT
Browse files Browse the repository at this point in the history
WQ
Merge branch 'development' into math_library_example
  • Loading branch information
saurabh-s-sawant committed Aug 26, 2024
2 parents 6a6a61d + 4d7e4f0 commit d1b30a1
Show file tree
Hide file tree
Showing 104 changed files with 15,171 additions and 13,795 deletions.
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
BasedOnStyle: Google # You can use LLVM, Google, Mozilla, or any other base style
IndentWidth: 4 # Number of spaces per indentation level
UseTab: Never # Do not use tabs, only spaces
TabWidth: 4 # Number of spaces per tab
ColumnLimit: 80
BreakBeforeBraces: Allman
PenaltyBreakBeforeFirstCallParameter: 100
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.ipynb linguist-detectable=false
*.md linguist-documentation=true

*.cpp linguist-language=C++
*.H linguist-language=C++
2 changes: 2 additions & 0 deletions .github/workflows/codespell-ignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
thi
PTD
23 changes: 23 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: codespell

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-codespell
cancel-in-progress: true

jobs:
codespell:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install codespell
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends python3-pip
pip3 install --user codespell
- name: Run codespell
run: codespell --ignore-words .github/workflows/codespell-ignore.txt --skip "*.py,*.ipynb"
22 changes: 22 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Style

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-style
cancel-in-progress: true

jobs:
tabs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Tabs
run: .github/workflows/style/check_tabs.sh

trailing_whitespaces:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Trailing Whitespaces
run: .github/workflows/style/check_trailing_whitespaces.sh
36 changes: 36 additions & 0 deletions .github/workflows/style/check_tabs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -eu -o pipefail

find . -type d \( -name .git \
-o -path ./paper \
-o -name build -o -name install \
-o -name tmp_build_dir -o -name tmp_install_dir \
\) -prune -o \
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \
-o -name "*.py" \
-o -name "*.md" -o -name "*.rst" \
-o -name "*.sh" \
-o -name "*.tex" \
-o -name "*.txt" \
-o -name "*.yml" \) \
-a \( ! -name "*.tab.h" -a ! -name "*.tab.nolint.H" \
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/\t/\ \ \ \ /g' {} +

gitdiff=`git diff`

if [ -z "$gitdiff" ]
then
exit 0
else
echo -e "\nTabs are not allowed. Changes suggested by"
echo -e " ${0}\n"
git --no-pager diff
echo ""
exit 1
fi
36 changes: 36 additions & 0 deletions .github/workflows/style/check_trailing_whitespaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -eu -o pipefail

find . -type d \( -name .git \
-o -path ./paper \
-o -name build -o -name install \
-o -name tmp_build_dir -o -name tmp_install_dir \
\) -prune -o \
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \
-o -name "*.py" \
-o -name "*.rst" \
-o -name "*.sh" \
-o -name "*.tex" \
-o -name "*.txt" \
-o -name "*.yml" \) \
-a \( ! -name "*.tab.h" -a ! -name "*.tab.nolint.H" \
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/[[:blank:]]\+$//g' {} +

gitdiff=`git diff`

if [ -z "$gitdiff" ]
then
exit 0
else
echo -e "\nTrailing whitespaces at the end of a line are not allowed. Changes suggested by"
echo -e " ${0}\n"
git --no-pager diff
echo ""
exit 1
fi
15 changes: 15 additions & 0 deletions Legal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Exascale-Enabled Models and Algorithms for Microelectronics Applications (MicroEleX)
Copyright (c) 2024, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any
required approvals from the U.S. Dept. of Energy). All rights reserved.

If you have questions about your rights to use or distribute this software,
please contact Berkeley Lab's Intellectual Property Office at
[email protected].

NOTICE. This Software was developed under funding from the U.S. Department
of Energy and the U.S. Government consequently retains certain rights. As
such, the U.S. Government has been granted for itself and others acting on
its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the
Software to reproduce, distribute copies to the public, prepare derivative
works, and perform publicly and display publicly, and to permit others to do so.
140 changes: 77 additions & 63 deletions Source/Code.H
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#ifndef CODE_H_
#define CODE_H_

#include "Input/GeometryProperties/GeometryProperties_fwd.H"
#include "Input/BoundaryConditions/BoundaryConditions_fwd.H"
#include "Input/GeometryProperties/GeometryProperties_fwd.H"
#include "Input/MacroscopicProperties/MacroscopicProperties_fwd.H"
#ifdef USE_TRANSPORT
#include "Solver/Transport/Transport_fwd.H"
#endif

#include "Solver/Electrostatics/MLMG_fwd.H"
#include "PostProcessor/PostProcessor_fwd.H"
#include <AMReX.H>

#include "Diagnostics/Diagnostics_fwd.H"
#include "Output/Output_fwd.H"
#include "PostProcessor/PostProcessor_fwd.H"
#include "Solver/Electrostatics/MLMG_fwd.H"
#include "Utils/SelectWarpXUtils/WarnManager_fwd.H"


#include <AMReX.H>
//#include <AMReX_AmrCore.H>
//#include <AMReX_Array.H>
//#include <AMReX_Config.H>
Expand All @@ -37,16 +36,14 @@
//#include <string>
//#include <vector>


//#include <AMReX_AmrCoreFwd.H>


enum class WarnPriority
{
/** Low priority warning:
* essentially an informative message
*/
low,
low,
/** Medium priority warning:
* a bug or a performance issue may affect the simulation
*/
Expand All @@ -60,87 +57,105 @@ enum class WarnPriority

class c_Code
{
public:
c_Code(); // constructor
~c_Code(); // destructor

public:

c_Code (); //constructor
~c_Code (); //destructor

/********************* FUNCTIONS/PARAMETERS TAKEN FROM WARPX
* ****************************/

/********************* FUNCTIONS/PARAMETERS TAKEN FROM WARPX ****************************/

static c_Code& GetInstance ();
static void ResetInstance ();
static c_Code &GetInstance();
static void ResetInstance();

/**
* \brief This function is borrowed from WarpX. It records a warning message.
* RecordWarning is thread safe: it can be used within OpenMP parallel loops.
* \brief This function is borrowed from WarpX. It records a warning
* message. RecordWarning is thread safe: it can be used within OpenMP
* parallel loops.
*
* @param[in] topic a string to identify the topic of the warning
* @param[in] topic a string to identify the topic of the warning
* (e.g., "parallelization", "pbc", "particles"...)
* @param[in] text the text of the warning message
* @param[in] priority priority of the warning message ("medium" by default)
*/
void RecordWarning(
std::string topic,
std::string text,
WarnPriority priority = WarnPriority::medium);
void RecordWarning(std::string topic, std::string text,
WarnPriority priority = WarnPriority::medium);

/**
* \brief This function prints all the warning messages collected on the present MPI rank
* (i.e., this is not a collective call). This function is mainly intended for debug purposes.
* \brief This function prints all the warning messages collected on the
* present MPI rank (i.e., this is not a collective call). This function is
* mainly intended for debug purposes.
*
* @param[in] when a string to mark when the warnings are printed out (it appears in the warning list)
* @param[in] when a string to mark when the warnings are printed out (it
* appears in the warning list)
*/
void PrintLocalWarnings(const std::string& when);
void PrintLocalWarnings(const std::string &when);

/**
* \brief This function prints all the warning messages collected by all the MPI ranks
* (i.e., this is a collective call). Only the I/O rank prints the message.
* \brief This function prints all the warning messages collected by all the
* MPI ranks (i.e., this is a collective call). Only the I/O rank prints the
* message.
*
* @param[in] when a string to mark when the warnings are printed out (it appears in the warning list)
* @param[in] when a string to mark when the warnings are printed out (it
* appears in the warning list)
*/
void PrintGlobalWarnings(const std::string& when);


std::unique_ptr<Utils::WarnManager> m_p_warn_manager; //Warning manager: used to record and print error msgs.
bool m_always_warn_immediately = false; //flag to emit control emitting warning as soon as it is recorded
void PrintGlobalWarnings(const std::string &when);

/****************************************************************************************/
std::unique_ptr<Utils::WarnManager>
m_p_warn_manager; // Warning manager: used to record and print error
// msgs.
bool m_always_warn_immediately =
false; // flag to emit control emitting
// warning as soon as it is recorded

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

void ReadData ();
void InitData ();
void Solve_PostProcess_Output ();
void ReadData();
void InitData();
void Solve_PostProcess_Output();
amrex::Real Solve_OnlyElectrostatics();
void Cleanup ();
void Cleanup();

void EstimateOfRequiredMemory();

static bool do_device_synchronize;

c_GeometryProperties& get_GeometryProperties () { return *m_pGeometryProperties;}
c_BoundaryConditions& get_BoundaryConditions () { return *m_pBoundaryConditions;}
c_MacroscopicProperties& get_MacroscopicProperties () { return *m_pMacroscopicProperties;}
#ifdef USE_TRANSPORT
c_TransportSolver& get_TransportSolver () { return *m_pTransportSolver;}
#endif
c_MLMGSolver& get_MLMGSolver () { return *m_pMLMGSolver;}
c_PostProcessor& get_PostProcessor () { return *m_pPostProcessor;}
c_Diagnostics& get_Diagnostics () { return *m_pDiagnostics;}
c_Output& get_Output () { return *m_pOutput;}

amrex::Real get_time() { return m_time_instant;}
amrex::Real get_step() { return static_cast<int>(m_time_instant/m_timestep);}
c_GeometryProperties &get_GeometryProperties()
{
return *m_pGeometryProperties;
}
c_BoundaryConditions &get_BoundaryConditions()
{
return *m_pBoundaryConditions;
}
c_MacroscopicProperties &get_MacroscopicProperties()
{
return *m_pMacroscopicProperties;
}
#ifdef USE_TRANSPORT
c_TransportSolver &get_TransportSolver() { return *m_pTransportSolver; }
#endif
c_MLMGSolver &get_MLMGSolver() { return *m_pMLMGSolver; }
c_PostProcessor &get_PostProcessor() { return *m_pPostProcessor; }
c_Diagnostics &get_Diagnostics() { return *m_pDiagnostics; }
c_Output &get_Output() { return *m_pOutput; }

amrex::Real get_time() { return m_time_instant; }
amrex::Real get_step()
{
return static_cast<int>(m_time_instant / m_timestep);
}
int use_diagnostics;
int use_transport;
int use_electrostatic;

private:
amrex::Real set_time(int n)
{ m_time_instant = n*m_timestep; return m_time_instant;}

static c_Code* m_instance;
private:
amrex::Real set_time(int n)
{
m_time_instant = n * m_timestep;
return m_time_instant;
}

static c_Code *m_instance;

amrex::Real m_time_instant = 0.;
amrex::Real m_timestep = 1.;
Expand All @@ -154,11 +169,10 @@ private:
std::unique_ptr<c_MLMGSolver> m_pMLMGSolver;
std::unique_ptr<c_PostProcessor> m_pPostProcessor;
std::unique_ptr<c_Output> m_pOutput;
#ifdef USE_TRANSPORT
#ifdef USE_TRANSPORT
std::unique_ptr<c_TransportSolver> m_pTransportSolver;
#endif
#endif

std::unique_ptr<c_Diagnostics> m_pDiagnostics;

};
#endif
Loading

0 comments on commit d1b30a1

Please sign in to comment.