Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluid/feature python solver derivation #2262

Merged
merged 28 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9a1ec94
Deriving fluid solvers from PythonSolver.
jcotela May 30, 2018
2182cc7
Adapting the fluid base solver to match the PythonSolver structure.
jcotela May 30, 2018
fdcd7c9
Separating Import and Prepare model part methods.
jcotela May 30, 2018
288cd08
Renaming base class and updating method names to match guidelines.
jcotela Jun 1, 2018
283a43d
Adding _ValidateSettings method to check parameters.
jcotela Jun 1, 2018
5f46100
First attempt at derivation.
jcotela Jun 1, 2018
c74aea5
Updating python solvers wrapper for the fluid.
jcotela Jun 1, 2018
8a9cf4d
Making monolithic solver test run (assorted typos and bugfixes),
jcotela Jun 1, 2018
62d2b76
Updating Fractional Step solvers.
jcotela Jun 1, 2018
81bbb15
Fixing issue with restart initialization order.
jcotela Jun 1, 2018
44a1e37
Porting trilinos monolithic solver + changes in trilinos FS solver.
jcotela Jun 1, 2018
a924644
Deriving the compressible solver from FluidSolver.
jcotela Jun 1, 2018
7373be5
Fixing last commit.
jcotela Jun 1, 2018
e1bb5b6
Bugfix: non-threadsafe access to processinfo in vms.
jcotela May 28, 2018
4364dc5
Solving initialization order issue with _ValidateSettings.
jcotela Jun 1, 2018
ad0cb37
WIP: Ongoing work on the embedded solver (and fixing its tests).
jcotela Jun 1, 2018
d6f4785
Updating manufactured solution test (it works now).
jcotela Jun 4, 2018
32b6f35
Updating embedded ausas solver.
jcotela Jun 4, 2018
7f6ffcd
All tests in queue \"all\" pass now.
jcotela Jun 4, 2018
b96b4b4
Porting FM-ALE solver and changing a few solver defaults.
jcotela Jun 4, 2018
f8c0b86
Physical property assignment now in PrepareModelPart for all solvers.
jcotela Jun 4, 2018
126e759
Updating steady navier stokes solver to new format.
jcotela Jun 4, 2018
7dec61c
Updating trilinos embedded solvers.
jcotela Jun 4, 2018
1dc5f57
Fixing a few typos.
jcotela Jun 4, 2018
00d10a8
Merging recent changes.
jcotela Jun 5, 2018
9abc76d
Removing debug print.
jcotela Jun 5, 2018
66ba1e8
Editing error message.
jcotela Jun 5, 2018
9ec9639
Removing an unreachable check (impossible condition) and some prints.
jcotela Jun 5, 2018
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
6 changes: 4 additions & 2 deletions applications/FluidDynamicsApplication/custom_elements/vms.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ class VMS : public Element
this->AddMomentumRHS(rRightHandSideVector, Density, N, Area);

// For OSS: Add projection of residuals to RHS
if (rCurrentProcessInfo[OSS_SWITCH] == 1)
const ProcessInfo& r_const_process_info = rCurrentProcessInfo;
if (r_const_process_info[OSS_SWITCH] == 1)
{
array_1d<double, 3 > AdvVel;
this->GetAdvectiveVel(AdvVel, N);
Expand Down Expand Up @@ -353,7 +354,8 @@ class VMS : public Element
These terms are not used in OSS, as they belong to the finite element
space and cancel out with their projections.
*/
if (rCurrentProcessInfo[OSS_SWITCH] != 1)
const ProcessInfo& r_const_process_info = rCurrentProcessInfo;
if (r_const_process_info[OSS_SWITCH] != 1)
{
double ElemSize = this->ElementSize(Area);
double Viscosity = this->EffectiveViscosity(Density,N,DN_DX,ElemSize,rCurrentProcessInfo);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import KratosMultiphysics
import KratosMultiphysics.FluidDynamicsApplication
import KratosMultiphysics
import KratosMultiphysics.FluidDynamicsApplication

def Factory(settings, Model):
if(type(settings) != KratosMultiphysics.Parameters):
Expand All @@ -10,52 +10,45 @@ def Factory(settings, Model):
class CheckAndPrepareModelProcess(KratosMultiphysics.Process):
def __init__(self, main_model_part, Parameters ):
self.main_model_part = main_model_part

self.volume_model_part_name = Parameters["volume_model_part_name"].GetString()
self.skin_name_list = Parameters["skin_parts"]


#self.volume_model_part_name = Parameters["volume_model_part_name"].GetString()
#self.list_of_inlets = Parameters["list_of_inlets"]
#self.list_of_slip = Parameters["list_of_inlets"]
#self.list_of_inlets = Parameters["list_of_inlets"]



def Execute(self):
self.volume_model_part = self.main_model_part.GetSubModelPart(self.volume_model_part_name)

skin_parts = []
for i in range(self.skin_name_list.size()):
skin_parts.append(self.main_model_part.GetSubModelPart(self.skin_name_list[i].GetString()))

#construct a model part which contains both the skin and the volume
#temporarily we call it "fluid_computational_model_part"
self.main_model_part.CreateSubModelPart("fluid_computational_model_part")
fluid_computational_model_part= self.main_model_part.GetSubModelPart("fluid_computational_model_part")
fluid_computational_model_part.ProcessInfo = self.main_model_part.ProcessInfo

print("adding nodes and elements to fluid_computational_model_part")

for node in self.volume_model_part.Nodes:
fluid_computational_model_part.AddNode(node,0)
for elem in self.volume_model_part.Elements:
fluid_computational_model_part.AddElement(elem,0)

#do some gymnastics to have this done fast. - create an ordered list to be added
list_of_ids = set()
for part in skin_parts:
for cond in part.Conditions:
list_of_ids.add(cond.Id)

fluid_computational_model_part.AddConditions(list(list_of_ids))

print(fluid_computational_model_part)

if(self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 3 and self.main_model_part.GetCommunicator().TotalProcesses() == 0 ):
#verify that the skin is correct (no gaps and overlaps)
KratosMultiphysics.CheckSkinProcess(fluid_computational_model_part , KratosMultiphysics.Flags()).Execute()

#verify the orientation of the skin
throw_errors = False
KratosMultiphysics.TetrahedralMeshOrientationCheck(fluid_computational_model_part,throw_errors).Execute()

Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,39 @@ def __init__(self,model,parameters):
else:
self.is_printing_rank = True

## Create model part and solver (but don't initialize them yet)
model_part_name = self.project_parameters["problem_data"]["model_part_name"].GetString()
self.main_model_part = Kratos.ModelPart(model_part_name)
# Deprecation warnings
solver_settings = self.project_parameters["solver_settings"]
if not solver_settings.Has("domain_size"):
Kratos.Logger.PrintInfo("FluidDynamicsAnalysis", "Using the old way to pass the domain_size, this will be removed!")
solver_settings.AddEmptyValue("domain_size")
solver_settings["domain_size"].SetInt(self.project_parameters["problem_data"]["domain_size"].GetInt())

if not solver_settings.Has("model_part_name"):
Kratos.Logger.PrintInfo("FluidDynamicsAnalysis", "Using the old way to pass the model_part_name, this will be removed!")
solver_settings.AddEmptyValue("model_part_name")
solver_settings["model_part_name"].SetString(self.project_parameters["problem_data"]["model_part_name"].GetString())

import python_solvers_wrapper_fluid
self.solver = python_solvers_wrapper_fluid.CreateSolver(self.main_model_part, self.project_parameters)
self.solver = python_solvers_wrapper_fluid.CreateSolver(model, self.project_parameters)

self.__restart_utility = None

def Initialize(self):
'''
Construct and initialize all classes and tools used in the simulation loop.
'''
domain_size = self.project_parameters["problem_data"]["domain_size"].GetInt()
self.main_model_part.ProcessInfo.SetValue(Kratos.DOMAIN_SIZE, domain_size)

self._SetUpRestart()

if self.load_restart:
self.restart_utility.LoadRestart()
restart_utility = self._GetRestartUtility()
restart_utility.LoadRestart()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is in the baseclass now

Also I am writing a process for saving restarts atm such that one does not have to manually include it in each stage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will come in #2135? I'll update once that is merged, then.

else:
self.solver.AddVariables()
self.solver.ImportModelPart()
self.solver.PrepareModelPart()
self.solver.AddDofs()

self.model.AddModelPart(self.main_model_part)
self.main_model_part = self.model.GetModelPart(self.project_parameters["solver_settings"]["model_part_name"].GetString())

# this should let eventual derived stages modify the model after reading.
self.ModifyInitialProperties()
Expand Down Expand Up @@ -83,7 +92,8 @@ def OutputSolutionStep(self):
process.ExecuteAfterOutputStep()

if self.save_restart:
self.restart_utility.SaveRestart()
restart_utility = self._GetRestartUtility()
restart_utility.SaveRestart()

def _SetUpListOfProcesses(self):
'''
Expand Down Expand Up @@ -157,17 +167,29 @@ def _SetUpRestart(self):
restart_settings.RemoveValue("save_restart")
restart_settings.AddValue("input_filename", self.project_parameters["problem_data"]["problem_name"])
restart_settings.AddValue("echo_level", self.project_parameters["problem_data"]["echo_level"])
else:
self.load_restart = False
self.save_restart = False

def _GetRestartUtility(self):

if self.__restart_utility is not None:
return self.__restart_utility
else:
if self.parallel_type == "OpenMP":
from restart_utility import RestartUtility as Restart
elif self.parallel_type == "MPI":
from trilinos_restart_utility import TrilinosRestartUtility as Restart

self.restart_utility = Restart(self.main_model_part,
self.project_parameters["restart_settings"])
else:
self.load_restart = False
self.save_restart = False
model_part_name = self.project_parameters["solver_settings"]["model_part_name"].GetString()
if self.model.HasModelPart(model_part_name):
model_part = self.model.GetModelPart(model_part_name)
else:
model_part = self.model.CreateModelPart(model_part_name)

self.__restart_utility = Restart(model_part,
self.project_parameters["restart_settings"])


if __name__ == '__main__':
from sys import argv
Expand Down
Loading