Skip to content
Snippets Groups Projects
Commit 38003171 authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Merge branch 'fix/FileFunctionReading' into 'master'

Fix: Dont read the same files again for every variable

This branch adds a check to prevent EquationSystem from reading the same fld/pts files again for each variable. This gives a huge speedup in some cases.

I also split the EquationSystem::EvaluateFunction method into three new methods: one for expressions, one for fld files and one for pts files to make the code more readable.

However, i think its still a mess with lots of duplicate code and even more things that would make much more sense in some other class. Even worse is that the Forcing base class holds a complete copy of this code.  I would like to move the whole Function logic from Forcing and EquationSystem into a new class that lives in SolverUtils in the future. Should we discuss that here or do you want me to write to the mailing list?

See merge request !670
parents 8a377d39 aafb6449
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ v4.4.0
- Fix bug in the calculation of the RHS magnitude in CG solver (!721)
- Fix bug in CMake Homebrew and MacPorts detection for OS X (!729)
- Fix bug in FieldUtils when using half mode expansions (!734)
- Do not read the same fld/pts files again for every variable (!670)
- Fix bug in CMake PETSc detection for Ubuntu 16.04/Debian 9 (!735)
**ADRSolver:**
......
This diff is collapsed.
......@@ -66,6 +66,11 @@ namespace Nektar
> EquationSystemFactory;
SOLVER_UTILS_EXPORT EquationSystemFactory& GetEquationSystemFactory();
struct loadedFldField {
std::vector<LibUtilities::FieldDefinitionsSharedPtr> fieldDef;
std::vector<std::vector<NekDouble> > fieldData;
} ;
/// A base class for describing how to solve specific equations.
class EquationSystem : public boost::enable_shared_from_this<EquationSystem>
{
......@@ -455,6 +460,10 @@ namespace Nektar
LibUtilities::FieldIOSharedPtr m_fld;
/// Map of interpolator objects
std::map<std::string, FieldUtils::Interpolator > m_interpolators;
/// pts fields we already read from disk: {funcFilename: (filename, ptsfield)}
std::map<std::string, std::pair<std::string, LibUtilities::PtsFieldSharedPtr> > m_loadedPtsFields;
// fld fiels already loaded from disk: {funcFilename: (filename, loadedFldField)}
std::map<std::string, std::pair<std::string, loadedFldField> > m_loadedFldFields;
/// Array holding all dependent variables.
Array<OneD, MultiRegions::ExpListSharedPtr> m_fields;
/// Base fields.
......@@ -477,8 +486,6 @@ namespace Nektar
NekDouble m_timestep;
/// Lambda constant in real system if one required.
NekDouble m_lambda;
std::set<std::string> m_loadedFields;
/// Time between checkpoints.
NekDouble m_checktime;
/// Number of checkpoints written so far
......@@ -596,6 +603,34 @@ namespace Nektar
unsigned int field,
Array<OneD, NekDouble> &outfield,
const NekDouble time);
// Populate an array with a function variable from session.
SOLVER_UTILS_EXPORT void EvaluateFunctionExp(
std::string pFieldName,
Array<OneD, NekDouble>& pArray,
const std::string& pFunctionName,
const NekDouble& pTime = 0.0,
const int domain = 0);
// Populate an array with a function variable from session.
SOLVER_UTILS_EXPORT void EvaluateFunctionFld(
std::string pFieldName,
Array<OneD, NekDouble>& pArray,
const std::string& pFunctionName,
const NekDouble& pTime = 0.0,
const int domain = 0);
SOLVER_UTILS_EXPORT void EvaluateFunctionPts(
std::string pFieldName,
Array<OneD, NekDouble>& pArray,
const std::string& pFunctionName,
const NekDouble& pTime = 0.0,
const int domain = 0);
SOLVER_UTILS_EXPORT void LoadPts(
std::string funcFilename,
std::string filename,
Nektar::LibUtilities::PtsFieldSharedPtr &outPts);
//Initialise m_base in order to store the base flow from a file
SOLVER_UTILS_EXPORT void SetUpBaseFields(SpatialDomains::MeshGraphSharedPtr &mesh);
......
......@@ -342,8 +342,7 @@
</REGION>
</BOUNDARYCONDITIONS>
<FUNCTION NAME="Baseflow"> <!-- Incompressible base flow -->
<F VAR="u0" TIMEDEPENDENT="1" FILE="APE_2DPulseInterp_baseflow_%14.8E.pts"/>
<E VAR="v0" VALUE="0"/>
<F VAR="u0,v0" TIMEDEPENDENT="1" FILE="APE_2DPulseInterp_baseflow_%14.8E.pts"/>
<E VAR="p0" VALUE="Pinfinity"/>
<E VAR="rho0" VALUE="Rho0"/>
</FUNCTION>
......
<?xml version="1.0" encoding="utf-8"?>
<NEKTAR>
<POINTS DIM="2" FIELDS="u0">
-1.0000 -1.0000 -1.0000
-0.5000 -1.0000 -1.0000
0.0000 -1.0000 -1.0000
0.5000 -1.0000 -1.0000
1.0000 -1.0000 -1.0000
-1.0000 -0.5000 -0.7000
-0.5000 -0.5000 -0.7000
0.0000 -0.5000 -0.7000
0.5000 -0.5000 -0.7000
1.0000 -0.5000 -0.7000
-1.0000 0.0000 0.0000
-0.5000 0.0000 0.0000
0.0000 0.0000 0.0000
0.5000 0.0000 0.0000
1.0000 0.0000 0.0000
-1.0000 0.5000 0.7000
-0.5000 0.5000 0.7000
0.0000 0.5000 0.7000
0.5000 0.5000 0.7000
1.0000 0.5000 0.7000
-1.0000 1.0000 1.0000
-0.5000 1.0000 1.0000
0.0000 1.0000 1.0000
0.5000 1.0000 1.0000
1.0000 1.0000 1.0000
<POINTS DIM="2" FIELDS="u0,v0">
-1.0000 -1.0000 -1.0000 0.0000
-0.5000 -1.0000 -1.0000 0.0000
0.0000 -1.0000 -1.0000 0.0000
0.5000 -1.0000 -1.0000 0.0000
1.0000 -1.0000 -1.0000 0.0000
-1.0000 -0.5000 -0.7000 0.0000
-0.5000 -0.5000 -0.7000 0.0000
0.0000 -0.5000 -0.7000 0.0000
0.5000 -0.5000 -0.7000 0.0000
1.0000 -0.5000 -0.7000 0.0000
-1.0000 0.0000 0.0000 0.0000
-0.5000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.5000 0.0000 0.0000 0.0000
1.0000 0.0000 0.0000 0.0000
-1.0000 0.5000 0.7000 0.0000
-0.5000 0.5000 0.7000 0.0000
0.0000 0.5000 0.7000 0.0000
0.5000 0.5000 0.7000 0.0000
1.0000 0.5000 0.7000 0.0000
-1.0000 1.0000 1.0000 0.0000
-0.5000 1.0000 1.0000 0.0000
0.0000 1.0000 1.0000 0.0000
0.5000 1.0000 1.0000 0.0000
1.0000 1.0000 1.0000 0.0000
</POINTS>
</NEKTAR>
<?xml version="1.0" encoding="utf-8"?>
<NEKTAR>
<POINTS DIM="2" FIELDS="u0">
-1.1000 -1.1000 -1.1000
-0.6000 -1.1000 -1.1000
0.0000 -1.1000 -1.1000
0.6000 -1.1000 -1.1000
1.1000 -1.1000 -1.1000
-1.1000 -0.6000 -0.8000
-0.6000 -0.6000 -0.8000
0.0000 -0.6000 -0.8000
0.6000 -0.6000 -0.8000
1.1000 -0.6000 -0.8000
-1.1000 0.0000 0.0000
-0.6000 0.0000 0.0000
0.0000 0.0000 0.0000
0.6000 0.0000 0.0000
1.1000 0.0000 0.0000
-1.1000 0.6000 0.8000
-0.6000 0.6000 0.8000
0.0000 0.6000 0.8000
0.6000 0.6000 0.8000
1.1000 0.6000 0.8000
-1.1000 1.1000 1.1000
-0.6000 1.1000 1.1000
0.0000 1.1000 1.1000
0.6000 1.1000 1.1000
1.1000 1.1000 1.1000
<POINTS DIM="2" FIELDS="u0,v0">
-1.1000 -1.1000 -1.1000 0.0000
-0.6000 -1.1000 -1.1000 0.0000
0.0000 -1.1000 -1.1000 0.0000
0.6000 -1.1000 -1.1000 0.0000
1.1000 -1.1000 -1.1000 0.0000
-1.1000 -0.6000 -0.8000 0.0000
-0.6000 -0.6000 -0.8000 0.0000
0.0000 -0.6000 -0.8000 0.0000
0.6000 -0.6000 -0.8000 0.0000
1.1000 -0.6000 -0.8000 0.0000
-1.1000 0.0000 0.0000 0.0000
-0.6000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.6000 0.0000 0.0000 0.0000
1.1000 0.0000 0.0000 0.0000
-1.1000 0.6000 0.8000 0.0000
-0.6000 0.6000 0.8000 0.0000
0.0000 0.6000 0.8000 0.0000
0.6000 0.6000 0.8000 0.0000
1.1000 0.6000 0.8000 0.0000
-1.1000 1.1000 1.1000 0.0000
-0.6000 1.1000 1.1000 0.0000
0.0000 1.1000 1.1000 0.0000
0.6000 1.1000 1.1000 0.0000
1.1000 1.1000 1.1000 0.0000
</POINTS>
</NEKTAR>
<?xml version="1.0" encoding="utf-8"?>
<NEKTAR>
<POINTS DIM="2" FIELDS="u0">
-1.2000 -1.2000 -1.2000
-0.7000 -1.2000 -1.2000
0.0000 -1.2000 -1.2000
0.7000 -1.2000 -1.2000
1.2000 -1.2000 -1.2000
-1.2000 -0.7000 -0.9000
-0.7000 -0.7000 -0.9000
0.0000 -0.7000 -0.9000
0.7000 -0.7000 -0.9000
1.2000 -0.7000 -0.9000
-1.2000 0.0000 0.0000
-0.7000 0.0000 0.0000
0.0000 0.0000 0.0000
0.7000 0.0000 0.0000
1.2000 0.0000 0.0000
-1.2000 0.7000 0.9000
-0.7000 0.7000 0.9000
0.0000 0.7000 0.9000
0.7000 0.7000 0.9000
1.2000 0.7000 0.9000
-1.2000 1.2000 1.2000
-0.7000 1.2000 1.2000
0.0000 1.2000 1.2000
0.7000 1.2000 1.2000
1.2000 1.2000 1.2000
<POINTS DIM="2" FIELDS="u0,v0">
-1.2000 -1.2000 -1.2000 0.0000
-0.7000 -1.2000 -1.2000 0.0000
0.0000 -1.2000 -1.2000 0.0000
0.7000 -1.2000 -1.2000 0.0000
1.2000 -1.2000 -1.2000 0.0000
-1.2000 -0.7000 -0.9000 0.0000
-0.7000 -0.7000 -0.9000 0.0000
0.0000 -0.7000 -0.9000 0.0000
0.7000 -0.7000 -0.9000 0.0000
1.2000 -0.7000 -0.9000 0.0000
-1.2000 0.0000 0.0000 0.0000
-0.7000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.7000 0.0000 0.0000 0.0000
1.2000 0.0000 0.0000 0.0000
-1.2000 0.7000 0.9000 0.0000
-0.7000 0.7000 0.9000 0.0000
0.0000 0.7000 0.9000 0.0000
0.7000 0.7000 0.9000 0.0000
1.2000 0.7000 0.9000 0.0000
-1.2000 1.2000 1.2000 0.0000
-0.7000 1.2000 1.2000 0.0000
0.0000 1.2000 1.2000 0.0000
0.7000 1.2000 1.2000 0.0000
1.2000 1.2000 1.2000 0.0000
</POINTS>
</NEKTAR>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment