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

Add chimera app #609

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a4ab2b9
Initial files for chimera app
jginternational Jun 13, 2019
69d32de
Load the tree
jginternational Jun 13, 2019
87176bf
Write as fluid
jginternational Jun 13, 2019
b04e020
Chimera parts parameters
jginternational Jun 13, 2019
087ccdb
Init write
jginternational Jun 13, 2019
9c99084
Write a file foreach patch #597
jginternational Jul 1, 2019
93ca2d8
Chimera cross example geometry
rubenzorrilla Jul 4, 2019
8ef1093
Conditions in cross example
rubenzorrilla Jul 4, 2019
fe60476
Merge branch 'master' into add-chimera-app
jginternational Jul 9, 2019
b01699d
Merge branch 'add-chimera-app' of https://github.com/KratosMultiphysi…
jginternational Jul 9, 2019
0490486
Merge branch 'master' into add-chimera-app
jginternational Oct 15, 2019
5d4757e
Merge branch 'master' into add-chimera-app
jginternational Jan 10, 2020
8dcece6
Commit masivo y fuera
jginternational Jan 10, 2020
8581e11
Write nodes in patches
jginternational Jan 14, 2020
3f4a058
Skip submodelpart print for ChimeraInternalBoundar
jginternational Jan 14, 2020
4f34a4b
Move to proper files
jginternational Jan 14, 2020
0680af8
typo
jginternational Jan 14, 2020
6676106
Write internal boundary conditions in each file
jginternational Jan 14, 2020
64c8936
write conditions by unique id
jginternational Jan 14, 2020
f6f4c49
Write submodelparts
jginternational Jan 14, 2020
3fa0bfc
Patch submodelpart
jginternational Jan 14, 2020
2c3a28c
Also project parameters
jginternational Jan 14, 2020
5de94af
Fluid materials write
jginternational Jan 15, 2020
1e687ca
update python
jginternational Jan 15, 2020
c3612b8
Merge branch 'master' into add-chimera-app
jginternational Mar 30, 2020
9386f0c
Merge branch 'master' into add-chimera-app
jginternational Feb 10, 2022
a493359
bring chimera app to this century
jginternational Feb 10, 2022
4a157d5
required changes to execute
jginternational Feb 10, 2022
3ae89f9
Merge branch 'master' into add-chimera-app
jginternational Feb 16, 2022
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
51 changes: 51 additions & 0 deletions kratos.gid/apps/Chimera/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"id": "Chimera",
"name": "Chimera",
"prefix": "Chim",
"themed": false,
"kratos_name": "FluidDynamicsApplication",
"python_packages": [
""
],
"dimensions": [
"2D"
],
"script_files": [
"start.tcl",
"examples/examples.tcl",
"examples/ChimeraCross.tcl",
"xml/XmlController.tcl",
"write/write.tcl",
"write/writeProjectParameters.tcl"
],
"start_script": "::Chimera::Init",
"requeriments": {
"apps": ["Fluid"],
"minimum_gid_version": "15.1.3d"
},
"permissions": {
"open_tree": true,
"show_toolbar": true,
"intervals": true,
"wizard": false
},
"unique_names": {
"parts": "FLParts",
"nodal_conditions": "FLNodalConditions",
"conditions": "FLBC",
"materials": "FLMaterials",
"results": "FLResults",
"drag": "FLDrags",
"time_parameters": "FLTimeParameters"
},
"write": {
"coordinates": "all",
"materials_file": "FluidMaterials.json",
"properties_location": "json",
"model_part_name": "FluidModelPart",
"output_model_part_name": "fluid_computational_model_part"
},
"main_launch_file": "python/KratosChimera.py",
"examples": "examples/examples.xml",
"description": ""
}
216 changes: 216 additions & 0 deletions kratos.gid/apps/Chimera/examples/ChimeraCross.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@

namespace eval ::Chimera::examples::ChimeraCross {
namespace path ::Chimera::examples
Kratos::AddNamespace [namespace current]
}

proc ::Chimera::examples::ChimeraCross::Init {args} {
if {![Kratos::IsModelEmpty]} {
set txt "We are going to draw the example geometry.\nDo you want to lose your previous work?"
set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel]
if { $retval == "cancel" } { return }
}
Kratos::ResetModel

DrawGeometry
AssignGroups
AssignMeshSizes
TreeAssignation

GiD_Process 'Redraw
GidUtils::UpdateWindow GROUPS
GidUtils::UpdateWindow LAYER
GiD_Process 'Zoom Frame
}

proc ::Chimera::examples::ChimeraCross::DrawGeometry {args} {
# Background mesh geometry creation
GiD_Layers create Background
GiD_Layers edit to_use Background

## Points ##
set back_coords [list 0.0 0.0 0.0 15.0 0.0 0.0 15.0 10.0 0.0 0.0 10.0 0.0]
set back_points [list ]
foreach {x y z} $back_coords {
lappend back_points [GiD_Geometry create point append Background $x $y $z]
}

## Lines ##
set back_lines [list ]
set initial [lindex $back_points 0]
foreach point [lrange $back_points 1 end] {
lappend back_lines [GiD_Geometry create line append stline Background $initial $point]
set initial $point
}
lappend back_lines [GiD_Geometry create line append stline Background $initial [lindex $back_points 0]]

## Surface ##
GiD_Process Mescape Geometry Create NurbsSurface {*}$back_lines escape escape

# Patch mesh geometry creation
GiD_Layers create Patch
GiD_Layers edit to_use Patch

## Points ##
set patch_coords [list 3.849 2.7749 0.0 8.0104 2.7749 0.0 8.0104 6.8667 0.0 3.849 6.8667 0.0]
set patch_points [list ]
foreach {x y z} $patch_coords {
lappend patch_points [GiD_Geometry create point append Patch $x $y $z]
}

## Lines ##
set patch_lines [list ]
set initial [lindex $patch_points 0]
foreach point [lrange $patch_points 1 end] {
lappend patch_lines [GiD_Geometry create line append stline Patch $initial $point]
set initial $point
}
lappend patch_lines [GiD_Geometry create line append stline Patch $initial [lindex $patch_points 0]]

# Cross mesh geometry creation
## Points ##
set cross_coords [list 5.0737 4.7791 0.0 5.7557 4.7791 0.0 5.7557 4.2084 0.0 5.9366 4.2084 0.0 5.9366 4.7791 0.0 6.7995 4.7791 0.0 6.7995 4.96 0.0 5.9366 4.96 0.0 5.9366 5.461 0.0 5.7557 5.461 0.0 5.7557 4.96 0.0 5.0737 4.96 0.0]
set cross_points [list ]
foreach {x y z} $cross_coords {
lappend cross_points [GiD_Geometry create point append Patch $x $y $z]
}

## Lines ##
set initial [lindex $cross_points 0]
foreach point [lrange $cross_points 1 end] {
lappend patch_lines [GiD_Geometry create line append stline Patch $initial $point]
set initial $point
}
lappend patch_lines [GiD_Geometry create line append stline Patch $initial [lindex $cross_points 0]]


## Surface ##
GiD_Process Mescape Geometry Create NurbsSurface {*}$patch_lines escape escape
}

# Group assign
proc ::Chimera::examples::ChimeraCross::AssignGroups {args} {
# Create the groups
GiD_Groups create Fluid
GiD_Groups edit color Fluid "#26d1a8ff"
GiD_EntitiesGroups assign Fluid surfaces {1 2}

GiD_Groups create Background
GiD_Groups edit color Background "#26d1a8ff"
GiD_EntitiesGroups assign Background surfaces 1

GiD_Groups create Patch
GiD_Groups edit color Patch "#26d1a8ff"
GiD_EntitiesGroups assign Patch surfaces 2

GiD_Groups create Inlet
GiD_Groups edit color Inlet "#e0210fff"
GiD_EntitiesGroups assign Inlet lines 4

GiD_Groups create Outlet
GiD_Groups edit color Outlet "#42eb71ff"
GiD_EntitiesGroups assign Outlet lines 2

GiD_Groups create No_Slip_Walls
GiD_Groups edit color No_Slip_Walls "#3b3b3bff"
GiD_EntitiesGroups assign No_Slip_Walls lines {1 3}

GiD_Groups create No_Slip_Cross
GiD_Groups edit color No_Slip_Cross "#3b3b3bff"
GiD_EntitiesGroups assign No_Slip_Cross lines {9 10 11 12 13 14 15 16 17 18 19 20}
}

# Mesh sizes
proc ::Chimera::examples::ChimeraCross::AssignMeshSizes {args} {
set cross_mesh_size 0.05
set surface_mesh_size 0.2
GiD_Process Mescape Meshing AssignSizes Lines $cross_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cross lines] escape escape
GiD_Process Mescape Meshing AssignSizes Lines $surface_mesh_size 5 7 8 6 escape escape
GiD_Process Mescape Meshing AssignSizes Surfaces $surface_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape
Kratos::Event_BeforeMeshGeneration $surface_mesh_size
}

# Tree assign
proc ::Chimera::examples::ChimeraCross::TreeAssignation {args} {
set nd $::Model::SpatialDimension
set root [customlib::GetBaseRoot]

set condtype line
if {$nd eq "3D"} { set condtype surface }

# Monolithic solution strategy set
spdAux::SetValueOnTreeItem v "Monolithic" FLSolStrat

# Fluid Parts
set fluidParts [spdAux::getRoute "FLParts"]
set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid]
set props [list Element Monolithic$nd ConstitutiveLaw Newtonian DENSITY 1000.0 DYNAMIC_VISCOSITY 0.001]
foreach {prop val} $props {
set propnode [$fluidNode selectNodes "./value\[@n = '$prop'\]"]
if {$propnode ne "" } {
$propnode setAttribute v $val
} else {
W "Warning - Couldn't find property Fluid $prop"
}
}

# Chimera Patches
set chimeraPatches [spdAux::getRoute "ChimParts"]
set chimeraNode [customlib::AddConditionGroupOnXPath $chimeraPatches Patch]
set chimera_patch_props [list overlap_distance 0.7]
foreach {prop val} $chimera_patch_props {
set propnode [$chimeraNode selectNodes "./value\[@n = '$prop'\]"]
if {$propnode ne ""} {
$propnode setAttribute v $val
} else {
W "Warning - Couldn't find property Chimera patches $prop"
}
}

# Set conditions
set fluidConditions [spdAux::getRoute "FLBC"]
ErasePreviousIntervals

# Fluid Inlet
::Fluid::xml::CreateNewInlet Inlet {new false name Total ini 0 end 1} true 1.0

# Fluid Outlet
set fluidOutlet "$fluidConditions/condition\[@n='Outlet$nd'\]"
set outletNode [customlib::AddConditionGroupOnXPath $fluidOutlet Outlet]
$outletNode setAttribute ov $condtype
set props [list value 0.0]
foreach {prop val} $props {
set propnode [$outletNode selectNodes "./value\[@n = '$prop'\]"]
if {$propnode ne "" } {
$propnode setAttribute v $val
} else {
W "Warning - Couldn't find property Outlet $prop"
}
}

# Fluid Conditions
[customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Walls] setAttribute ov $condtype
[customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Cross] setAttribute ov $condtype
[customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='ChimeraInternalBoundary$nd'\]" No_Slip_Cross] setAttribute ov $condtype

# Time parameters
set time_parameters [list EndTime 1.0 DeltaTime 0.01]
set time_params_path [spdAux::getRoute "FLTimeParameters"]
foreach {n v} $time_parameters {
[$root selectNodes "$time_params_path/value\[@n = '$n'\]"] setAttribute v $v
}
# Output
set time_parameters [list OutputControlType step OutputDeltaStep 1]
set xpath "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]/container\[@n='GiDOptions'\]"
foreach {n v} $time_parameters {
[$root selectNodes "$xpath/value\[@n = '$n'\]"] setAttribute v $v
}
# Parallelism
set time_parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4]
set time_params_path [spdAux::getRoute "Parallelization"]
foreach {n v} $time_parameters {
[$root selectNodes "$time_params_path/value\[@n = '$n'\]"] setAttribute v $v
}

spdAux::RequestRefresh
}
20 changes: 20 additions & 0 deletions kratos.gid/apps/Chimera/examples/examples.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace eval ::Chimera::examples {
namespace path ::Chimera
Kratos::AddNamespace [namespace current]

}

proc ::Chimera::examples::ErasePreviousIntervals { } {
set root [customlib::GetBaseRoot]
set interval_base [spdAux::getRoute "Intervals"]
foreach int [$root selectNodes "$interval_base/blockdata\[@n='Interval'\]"] {
if {[$int @name] ni [list Initial Total Custom1]} {$int delete}
}
}

proc ::Chimera::examples::AddCuts { } {
# Cuts
set results "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]"
set cp [[customlib::GetBaseRoot] selectNodes "$results/container\[@n = 'CutPlanes'\]/blockdata\[@name = 'CutPlane'\]"]
[$cp selectNodes "./value\[@n = 'point'\]"] setAttribute v "0.0,0.5,0.0"
}
11 changes: 11 additions & 0 deletions kratos.gid/apps/Chimera/examples/examples.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Group id="Chimera" name="Chimera examples">
<Example id="ChimeraCross2D" app="Chimera" logo="HighRiseBuilding2D.png" name="Chimera Cross" dim="2D" cmd="::Chimera::examples::ChimeraCross::Init">
<Description>This example applies an inlet condition to the air surrounding a 2D building.
The default mesh is made of 4.000 trianglular elements, and the calculation generates results for 800 timesteps.
- Size of model: 0.4 MB
- Time: Avg calulation time: 2 minutes
- Size with results: 250 MB
</Description>
</Example>
</Group>
Binary file added kratos.gid/apps/Chimera/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions kratos.gid/apps/Chimera/python/KratosChimera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7

import KratosMultiphysics
from KratosMultiphysics.ChimeraApplication.fluid_chimera_analysis import FluidChimeraAnalysis

import sys
import time

class FluidChimeraAnalysisWithFlush(FluidChimeraAnalysis):

def __init__(self,model,project_parameters,flush_frequency=10.0):
super(FluidChimeraAnalysisWithFlush,self).__init__(model,project_parameters)
self.flush_frequency = flush_frequency
self.last_flush = time.time()

def FinalizeSolutionStep(self):
super(FluidChimeraAnalysisWithFlush,self).FinalizeSolutionStep()

if self.parallel_type == "OpenMP":
now = time.time()
if now - self.last_flush > self.flush_frequency:
sys.stdout.flush()
self.last_flush = now

if __name__ == "__main__":

with open("ProjectParameters.json",'r') as parameter_file:
parameters = KratosMultiphysics.Parameters(parameter_file.read())

model = KratosMultiphysics.Model()
simulation = FluidChimeraAnalysisWithFlush(model,parameters)
simulation.Run()
24 changes: 24 additions & 0 deletions kratos.gid/apps/Chimera/start.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace eval ::Chimera {
Kratos::AddNamespace [namespace current]
# Variable declaration
variable dir
variable _app

proc GetAttribute {name} {variable _app; return [$_app getProperty $name]}
proc GetUniqueName {name} {variable _app; return [$_app getUniqueName $name]}
proc GetWriteProperty {name} {variable _app; return [$_app getWriteProperty $name]}
}
proc ::Chimera::Init { app } {

# Variable initialization
variable _app
variable dir

set _app $app
set dir [apps::getMyDir "Chimera"]

# XML init event
::Chimera::xml::Init
::Chimera::write::Init
}

Loading