Skip to content

Commit

Permalink
split variables will be read from a text file.
Browse files Browse the repository at this point in the history
  • Loading branch information
abtin98 committed Jul 15, 2019
1 parent 54b5854 commit dea37af
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 111 deletions.
1 change: 1 addition & 0 deletions src/dg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set(DG_SOURCE
dg.cpp
weak_dg.cpp
strong_dg.cpp
split_form.cpp
)

foreach(dim RANGE 1 3)
Expand Down
38 changes: 35 additions & 3 deletions src/dg/dg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/data_out_dof_data.h>


#include "dg.h"

namespace PHiLiP {
Expand Down Expand Up @@ -87,7 +86,7 @@ ::create_discontinuous_galerkin(

// DGBase ***************************************************************************
template <int dim, typename real>
DGBase<dim,real>::DGBase(
DGBase<dim,real>::DGBase( // @suppress("Class members should be properly initialized")
const int nstate_input,
const Parameters::AllParameters *const parameters_input,
const unsigned int degree)
Expand All @@ -100,7 +99,40 @@ DGBase<dim,real>::DGBase(
, oned_quadrature (degree+1)
, volume_quadrature (degree+1)
, face_quadrature (degree+1)
{ }
{
if (parameters_input->use_split_form == true)
{
std::string split_file_name = parameters_input->split_form_param.split_file_name;
int n_split_terms = parameters_input->split_form_param.n_split_terms;
std::ifstream myfile;
myfile.open(split_file_name);
myfile >> variables;


splitform::SplitForm<dim, real> spform; //contains one split form object.
std::vector <splitform::SplitForm<dim, real>> split_vector; //contains the split terms for one component.
split_vector.clear();

for (int i = 0; i < n_split_terms; ++i)
{
std::string alpha_string;
std::string::size_type sz;
myfile >> alpha_string;
if (alpha_string == "E")
{
splitform_list.push_back(split_vector); //E means the line has ended, which means we have covered all split forms for one component
//We thus add the split_vector to splitform_list.
//We're basically getting around not knowing n_state by using push_back.
continue;
}
spform.alpha = std::stod (alpha_string, &sz);

myfile >> spform.f;
myfile >> spform.g;
split_vector.push_back(spform); //adds one SplitForm object to split_vector
}
}
}

// Destructor
template <int dim, typename real>
Expand Down
11 changes: 5 additions & 6 deletions src/dg/dg.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "physics/physics.h"
#include "numerical_flux/numerical_flux.h"
#include "parameters/all_parameters.h"
#include "split_form/split_form.h"
#include "split_form.h"


namespace PHiLiP {
Expand Down Expand Up @@ -98,11 +98,10 @@ class DGBase


/// Vector of split form objects.
<<<<<<< HEAD
std::vector<splitform::SplitForm<dim, real>> splitform_list;
=======
std::vector<splitform::SplitForm> splitform_list;
>>>>>>> e7d98c56285053c6f4de58af53f548151e69d272
//Contains n_component x n_split_term SplitForm objects.
std::vector <std::vector<splitform::SplitForm<dim, real>>> splitform_list;
std::string variables;
std::map <std::string, double> constants;

/// Evaluates the maximum stable time step
/* If exact_time_stepping = true, use the same time step for the entire solution
Expand Down
22 changes: 22 additions & 0 deletions src/dg/split_form.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "split_form.h"

namespace PHiLiP {
namespace splitform {

template <int dim, typename real>
SplitForm<dim, real>::SplitForm()
{
alpha = 0;
f = "";
g = "";
}

template class SplitForm<1, double>;
template class SplitForm<2, double>;
template class SplitForm<3, double>;

} //splitform namespace



} //PHiLiP namespace
27 changes: 27 additions & 0 deletions src/dg/split_form.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef __SPLIT_FORM_H__
#define __SPLIT_FORM_H__

#include <iostream>
#include <vector>
#include "parameters/all_parameters.h"
#include <deal.II/base/function_parser.h>

namespace PHiLiP {
namespace splitform {
template <int dim, typename real>
class SplitForm
{
public:
SplitForm();

double alpha;
std::string f;
std::string g; //we can't use functionparser because we don't know how many state variables we have (which is a template argument we need to feed the functionparser

//FunctionParser<dim> fp;
//FunctionParser g_function;
void parse_functions(std::string fstring, std::string gstring);
};
} //splitform namespace
} //PHiLiP namespace
#endif
36 changes: 4 additions & 32 deletions src/parameters/parameters_split_form.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#include "parameters_split_form.h"

<<<<<<< HEAD
namespace PHiLiP {
=======

namespace PHiLiP{
>>>>>>> e7d98c56285053c6f4de58af53f548151e69d272
namespace Parameters {

SplitFormParam::SplitFormParam() {}

<<<<<<< HEAD
void SplitFormParam::declare_parameters (dealii::ParameterHandler &prm)
{
prm.enter_subsection("Split Form");
Expand All @@ -18,44 +14,20 @@ void SplitFormParam::declare_parameters (dealii::ParameterHandler &prm)
dealii::Patterns::Integer(0,dealii::Patterns::Integer::max_int_value),
"Indicates maximum number of split form terms present in discretization");

prm.declare_entry("Coefficient value", "1.0",
dealii::Patterns::Double(),
"The split form coefficients (alpha values");

prm.declare_entry("Left side function", "1",
prm.declare_entry("Split functions file", "split_functions.txt",
dealii::Patterns::Anything(),
"This is the function whose derivative isn't taken."
"In unsplit form, this is 1");

prm.declare_entry("Right side function", "1",
dealii::Patterns::Anything(),
"This is the function whose derivative is taken."
"In unsplit form, this is the convective flux");
"This is the file that contains all the relevant split functions and coefficients");
}
prm.leave_subsection();
=======
static void SplitFormParam::declare_parameters (dealii::ParameterHandler &prm)
{

>>>>>>> e7d98c56285053c6f4de58af53f548151e69d272
}

void SplitFormParam::parse_parameters (dealii::ParameterHandler &prm)
{
<<<<<<< HEAD
prm.enter_subsection("Split Form");
{
n_split_terms = prm.get_integer("Number of split form terms");
for (unsigned int i = 0; i < n_split_terms; ++i)
{
coefficient.push_back(prm.get_double("Coefficient value"));
f.push_back(prm.get("Left side function"));
g.push_back(prm.get("Right side function"));
}
split_file_name = prm.get("Split functions file");
}
=======

>>>>>>> e7d98c56285053c6f4de58af53f548151e69d272
}

} //Parameters namespace
Expand Down
12 changes: 2 additions & 10 deletions src/parameters/parameters_split_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@ namespace Parameters {

class SplitFormParam
{
<<<<<<< HEAD
public:
=======
>>>>>>> e7d98c56285053c6f4de58af53f548151e69d272

SplitFormParam ();


/// Declares the possible variables and sets the defaults.
static void declare_parameters (dealii::ParameterHandler &prm);
/// Parses input file and sets the variables.
void parse_parameters (dealii::ParameterHandler &prm);
<<<<<<< HEAD

std::vector<std::string> f; //left function. Need a better name for the variables...
std::vector<std::string> g; //right function
std::string split_file_name; //left function. Need a better name for the variables...
unsigned int n_split_terms;
std::vector<double> coefficient; //split form coefficients
=======
>>>>>>> e7d98c56285053c6f4de58af53f548151e69d272
};

} //Parameters namespace
Expand Down
20 changes: 0 additions & 20 deletions src/split_form/split_form.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions src/split_form/split_form.h

This file was deleted.

24 changes: 12 additions & 12 deletions tests/burgers_inviscid_implicit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ add_test(
WORKING_DIRECTORY ${TEST_OUTPUT_DIR}
)

configure_file(2d_burgers_inviscid_implicit.prm 2d_burgers_inviscid_implicit.prm COPYONLY)
add_test(
NAME 2D_BURGERS_INVISCID_IMPLICIT_MANUFACTURED_SOLUTION
COMMAND ${EXECUTABLE_OUTPUT_PATH}/PHiLiP_2D -i ${CMAKE_CURRENT_BINARY_DIR}/2d_burgers_inviscid_implicit.prm
WORKING_DIRECTORY ${TEST_OUTPUT_DIR}
)
# configure_file(2d_burgers_inviscid_implicit.prm 2d_burgers_inviscid_implicit.prm COPYONLY)
#add_test(
# NAME 2D_BURGERS_INVISCID_IMPLICIT_MANUFACTURED_SOLUTION
# COMMAND ${EXECUTABLE_OUTPUT_PATH}/PHiLiP_2D -i ${CMAKE_CURRENT_BINARY_DIR}/2d_burgers_inviscid_implicit.prm
# WORKING_DIRECTORY ${TEST_OUTPUT_DIR}
#)

configure_file(3d_burgers_inviscid_implicit.prm 3d_burgers_inviscid_implicit.prm COPYONLY)
add_test(
NAME 3D_BURGERS_INVISCID_IMPLICIT_MANUFACTURED_SOLUTION
COMMAND ${EXECUTABLE_OUTPUT_PATH}/PHiLiP_3D -i ${CMAKE_CURRENT_BINARY_DIR}/3d_burgers_inviscid_implicit.prm
WORKING_DIRECTORY ${TEST_OUTPUT_DIR}
)
# configure_file(3d_burgers_inviscid_implicit.prm 3d_burgers_inviscid_implicit.prm COPYONLY)
#add_test(
# NAME 3D_BURGERS_INVISCID_IMPLICIT_MANUFACTURED_SOLUTION
# COMMAND ${EXECUTABLE_OUTPUT_PATH}/PHiLiP_3D -i ${CMAKE_CURRENT_BINARY_DIR}/3d_burgers_inviscid_implicit.prm
# WORKING_DIRECTORY ${TEST_OUTPUT_DIR}
#)

0 comments on commit dea37af

Please sign in to comment.