14 #if !defined(KRATOS_COMPRESSIBLE_NAVIER_STOKES_EXPLICIT_SOLVING_STRATEGY_BASE)
15 #define KRATOS_COMPRESSIBLE_NAVIER_STOKES_EXPLICIT_SOLVING_STRATEGY_BASE
60 template <
typename TBaseExplicitStrategy>
62 :
public TBaseExplicitStrategy
98 ThisParameters = this->ValidateAndAssignParameters(ThisParameters, this->
GetDefaultParameters());
112 typename ExplicitBuilderType::Pointer pExplicitBuilder,
113 bool MoveMeshFlag =
false,
114 int RebuildLevel = 0)
115 :
BaseType(rModelPart, pExplicitBuilder, MoveMeshFlag, RebuildLevel)
126 bool MoveMeshFlag =
false,
127 int RebuildLevel = 0)
128 :
BaseType(rModelPart, MoveMeshFlag, RebuildLevel)
151 int err_code = BaseType::Check();
154 const auto& r_process_info = BaseType::GetModelPart().GetProcessInfo();
155 KRATOS_ERROR_IF_NOT(r_process_info.Has(OSS_SWITCH)) <<
"OSS_SWITCH variable has not been set in the ProcessInfo container. Please set it in the strategy \'Initialize\'." << std::endl;
175 "explicit_solving_strategy" : "",
176 "move_mesh_flag": false,
177 "calculate_non_conservative_magnitudes" : true,
178 "shock_capturing_settings" : { }
182 const Parameters base_default_parameters = BaseType::GetDefaultParameters();
183 default_parameters.RecursivelyAddMissingParameters(base_default_parameters);
184 return default_parameters;
196 BaseType::AssignSettings(ThisParameters);
197 mCalculateNonConservativeMagnitudes = ThisParameters[
"calculate_non_conservative_magnitudes"].
GetBool();
201 if (mpShockCapturingProcess && !mCalculateNonConservativeMagnitudes) {
202 KRATOS_WARNING(
"CompressibleNavierStokesExplicitSolvingStrategy4")
203 <<
"\'shock_capturing\' requires \'calculate_non_conservative_magnitudes\' to be active. Activating it." << std::endl;
204 mCalculateNonConservativeMagnitudes =
true;
215 auto& r_model_part = BaseType::GetModelPart();
216 const auto& r_process_info = r_model_part.GetProcessInfo();
218 BaseType::Initialize();
222 rNode.SetValue(MACH, 0.0);
223 rNode.SetValue(SOUND_VELOCITY, 0.0);
227 if (r_process_info[OSS_SWITCH]) {
229 rNode.SetValue(DENSITY_PROJECTION, 0.0);
230 rNode.SetValue(TOTAL_ENERGY_PROJECTION, 0.0);
231 rNode.SetValue(MOMENTUM_PROJECTION, ZeroVector(3));
262 BaseType::FinalizeSolutionStep();
286 virtual std::string
Info()
const override = 0;
289 virtual void PrintInfo(std::ostream &rOStream)
const override
295 virtual void PrintData(std::ostream &rOStream)
const override
327 "type" : "physics_based",
329 "model_part_name" : ""
333 defaults["Parameters"][
"model_part_name"].SetString(BaseType::GetModelPart().Name());
340 const std::map<const std::string, ShockCapturingFactoryType> shock_capturing_factory_map
343 {
"physics_based", [](
ModelPart&
m,
Parameters p) -> Process::UniquePointer {
return Kratos::make_unique<ShockCapturingPhysicsBasedProcess>(
m,
p);}},
344 {
"entropy_based", [](
ModelPart&
m,
Parameters p) -> Process::UniquePointer {
return Kratos::make_unique<ShockCapturingEntropyViscosityProcess>(
m,
p);}}
347 const auto sc_type = ShockCapturingParameters[
"type"].
GetString();
349 const auto it = shock_capturing_factory_map.find(sc_type);
350 if(it != shock_capturing_factory_map.end())
352 mpShockCapturingProcess = it->second(BaseType::GetModelPart(), ShockCapturingParameters[
"Parameters"]);
356 std::stringstream msg;
357 msg <<
"Provided shock capturing type \""<< sc_type <<
"\" does not match any of the available ones.\n";
358 msg <<
"Please choose one from the following list:\n";
359 for(
const auto& keyvaluepair: shock_capturing_factory_map)
361 msg <<
" - " << keyvaluepair.first <<
"\n";
374 auto& r_model_part = BaseType::GetModelPart();
375 const int n_nodes = r_model_part.NumberOfNodes();
376 const auto& r_process_info = r_model_part.GetProcessInfo();
377 const unsigned int block_size = r_process_info[DOMAIN_SIZE] + 2;
381 const auto p_explicit_bs = BaseType::pGetExplicitBuilder();
382 const auto& r_lumped_mass_vector = p_explicit_bs->GetLumpedMassMatrixVector();
386 rNode.GetValue(DENSITY_PROJECTION) = 0.0;
387 rNode.GetValue(MOMENTUM_PROJECTION) = ZeroVector(3);
388 rNode.GetValue(TOTAL_ENERGY_PROJECTION) = 0.0;
392 std::tuple<double, double, array_1d<double,3>> oss_proj_tls;
394 double& rho_proj = std::get<0>(rOssProjTLS);
395 double& tot_ener_proj = std::get<1>(rOssProjTLS);
396 array_1d<double,3>& mom_proj = std::get<2>(rOssProjTLS);
397 rElement.Calculate(DENSITY_PROJECTION, rho_proj, r_process_info);
398 rElement.Calculate(MOMENTUM_PROJECTION, mom_proj, r_process_info);
399 rElement.Calculate(TOTAL_ENERGY_PROJECTION, tot_ener_proj, r_process_info);
405 auto it_node = r_model_part.NodesBegin() + iNode;
406 const double nodal_area = r_lumped_mass_vector[iNode *
block_size];
407 it_node->GetValue(DENSITY_PROJECTION) /= nodal_area;
408 it_node->GetValue(MOMENTUM_PROJECTION) /= nodal_area;
409 it_node->GetValue(TOTAL_ENERGY_PROJECTION) /= nodal_area;
425 auto& r_model_part = BaseType::GetModelPart();
426 const auto& r_prop = r_model_part.ElementsBegin()->GetProperties();
427 const double c_v = r_prop.GetValue(SPECIFIC_HEAT);
428 const double gamma = r_prop.GetValue(HEAT_CAPACITY_RATIO);
429 const double R = (
gamma - 1.0) * c_v;
434 const auto& r_mom = rNode.FastGetSolutionStepValue(MOMENTUM);
435 const double& r_rho = rNode.FastGetSolutionStepValue(DENSITY);
436 const double& r_tot_ener = rNode.FastGetSolutionStepValue(TOTAL_ENERGY);
437 rVelocity = r_mom / r_rho;
438 const double temp = (r_tot_ener / r_rho - 0.5 * inner_prod(rVelocity, rVelocity)) / c_v;
439 const double sound_velocity = std::sqrt(gamma * R * temp);
440 rNode.FastGetSolutionStepValue(VELOCITY) = rVelocity;
441 rNode.FastGetSolutionStepValue(TEMPERATURE) = temp;
442 rNode.FastGetSolutionStepValue(PRESSURE) = r_rho * R * temp;
443 rNode.GetValue(SOUND_VELOCITY) = sound_velocity;
444 rNode.GetValue(MACH) = norm_2(rVelocity) / sound_velocity;
455 auto &r_model_part = BaseType::GetModelPart();
458 if (rNode.Is(SLIP)) {
459 auto unit_normal = rNode.FastGetSolutionStepValue(NORMAL);
460 unit_normal /= norm_2(unit_normal);
461 auto& r_mom = rNode.FastGetSolutionStepValue(MOMENTUM);
462 const double r_mom_n = inner_prod(r_mom, unit_normal);
463 noalias(r_mom) -= r_mom_n * unit_normal;
471 auto& r_model_part = BaseType::GetModelPart();
472 auto& r_process_info = r_model_part.GetProcessInfo();
475 if (r_process_info[OSS_SWITCH]) {
476 CalculateOrthogonalSubScalesProjection();
484 if (SlipConditionEnabled()) {
485 ApplySlipCondition();
491 return mpShockCapturingProcess !=
nullptr;
496 return mCalculateNonConservativeMagnitudes;
501 return mApplySlipCondition;
511 return mpShockCapturingProcess;
534 bool mFirstStep =
true;
535 bool mApplySlipCondition =
true;
536 bool mCalculateNonConservativeMagnitudes =
true;
537 Process::UniquePointer mpShockCapturingProcess =
nullptr;
Explicit solving strategy base class.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:63
TBaseExplicitStrategy::LocalSystemVectorType LocalSystemVectorType
The local vector definition.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:76
CompressibleNavierStokesExplicitSolvingStrategy(ModelPart &rModelPart, bool MoveMeshFlag=false, int RebuildLevel=0)
Default constructor.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:124
const Process::UniquePointer & GetShockCapturingProcess()
Definition: compressible_navier_stokes_explicit_solving_strategy.h:509
CompressibleNavierStokesExplicitSolvingStrategy(const CompressibleNavierStokesExplicitSolvingStrategy &Other)=delete
void SetUpShockCapturing(Parameters ShockCapturingParameters)
Definition: compressible_navier_stokes_explicit_solving_strategy.h:321
bool ShockCapturingEnabled() const noexcept
Definition: compressible_navier_stokes_explicit_solving_strategy.h:489
TBaseExplicitStrategy BaseType
The base class definition.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:70
void CalculateOrthogonalSubScalesProjection()
Definition: compressible_navier_stokes_explicit_solving_strategy.h:371
virtual ~CompressibleNavierStokesExplicitSolvingStrategy()=default
BaseType::ExplicitBuilderType ExplicitBuilderType
The explicit builder and solver definition.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:73
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:295
CompressibleNavierStokesExplicitSolvingStrategy(ModelPart &rModelPart, Parameters ThisParameters)
Default constructor. (with parameters)
Definition: compressible_navier_stokes_explicit_solving_strategy.h:90
virtual std::string Info() const override=0
Turn back information as a string.
void CalculateNonConservativeMagnitudes()
Calculates the non-conservative magnitudes This function calculates the non-conservative magnitudes f...
Definition: compressible_navier_stokes_explicit_solving_strategy.h:421
bool ConservativeMagnitudeCalculationEnabled() const noexcept
Definition: compressible_navier_stokes_explicit_solving_strategy.h:494
bool SlipConditionEnabled() const noexcept
Definition: compressible_navier_stokes_explicit_solving_strategy.h:499
KRATOS_CLASS_POINTER_DEFINITION(CompressibleNavierStokesExplicitSolvingStrategy)
Pointer definition of CompressibleNavierStokesExplicitSolvingStrategy.
virtual void Initialize() override
Initialization of member variables and prior operations In this method we call the base strategy init...
Definition: compressible_navier_stokes_explicit_solving_strategy.h:213
virtual void FinalizeEverySubstep()
Definition: compressible_navier_stokes_explicit_solving_strategy.h:480
void ApplySlipCondition()
Appy the slip condition This method substracts the normal projection of the momentum for all the node...
Definition: compressible_navier_stokes_explicit_solving_strategy.h:453
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:193
virtual void InitializeEverySubstep()
Definition: compressible_navier_stokes_explicit_solving_strategy.h:468
int Check() override
Definition: compressible_navier_stokes_explicit_solving_strategy.h:149
virtual void FinalizeSolutionStep() override
Finalize the step In this method we calculate the final linearised time derivatives after the final u...
Definition: compressible_navier_stokes_explicit_solving_strategy.h:260
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:169
virtual void InitializeSolutionStep() override
Definition: compressible_navier_stokes_explicit_solving_strategy.h:241
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:289
CompressibleNavierStokesExplicitSolvingStrategy(ModelPart &rModelPart, typename ExplicitBuilderType::Pointer pExplicitBuilder, bool MoveMeshFlag=false, int RebuildLevel=0)
Default constructor.
Definition: compressible_navier_stokes_explicit_solving_strategy.h:110
Base class for all Elements.
Definition: element.h:60
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
std::size_t SizeType
Definition: model_part.h:107
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void RecursivelyAddMissingParameters(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing contain at least all parameters...
Definition: kratos_parameters.cpp:1457
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_WARNING(label)
Definition: logger.h:265
void InitializeSolutionStep(ConstructionUtility &rThisUtil, std::string ThermalSubModelPartName, std::string MechanicalSubModelPartName, std::string HeatFluxSubModelPartName, std::string HydraulicPressureSubModelPartName, bool thermal_conditions, bool mechanical_conditions, int phase)
Definition: add_custom_utilities_to_python.cpp:45
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
ExplicitBuilder< SparseSpaceType, LocalSpaceType > ExplicitBuilderType
Definition: register_factories.h:37
int n_nodes
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:15
int block_size
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:16
float gamma
Definition: generate_two_fluid_navier_stokes.py:131
R
Definition: isotropic_damage_automatic_differentiation.py:172
tuple const
Definition: ode_solve.py:403
int m
Definition: run_marine_rain_substepping.py:8
p
Definition: sensitivityMatrix.py:52