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

[Core][MeshingApplication] Extend gradient process to other geometries. Reduce the number of template arguments to reduce compilation time #3702

Merged
merged 40 commits into from
Dec 30, 2018

Conversation

loumalouomega
Copy link
Member

This allows to use the gradient an Hessian with geometries different than triangles and tetras. Additionally it reduces significantly the number of template arguments required

@riccardotosi I will add the corrections you suggested on the Hessian in a future PR

@loumalouomega loumalouomega changed the title [Core] Extend gradient process to other geometries. Reduce the number of template arguments to reduce compilation time [Core][MeshingApplication] Extend gradient process to other geometries. Reduce the number of template arguments to reduce compilation time Dec 19, 2018
Copy link
Member

@philbucher philbucher left a comment

Choose a reason for hiding this comment

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

wasn't it you that introduced the template-args?

kratos/python/add_processes_to_python.cpp Show resolved Hide resolved
it_node->SetValue(ANISOTROPIC_RATIO, ratio);
const auto& it_element_begin = mThisModelPart.ElementsBegin();
const auto& r_first_element_geometry = it_element_begin->GetGeometry();
const std::size_t dimension = r_first_element_geometry.WorkingSpaceDimension();
Copy link
Member

Choose a reason for hiding this comment

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

I would say the processinfo is safer

Copy link
Member Author

Choose a reason for hiding this comment

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

For what?

Copy link
Member

Choose a reason for hiding this comment

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

determining the dimension of the problem

Co-Authored-By: loumalouomega <vicente.mataix@polytechnique.edu>
@philbucher
Copy link
Member

why do you make your algorithm to only consider the first element to determine the number of node, dimension?
I had the same comment in another PR of you some days ago

This can be easily broken!

@loumalouomega
Copy link
Member Author

loumalouomega commented Dec 20, 2018 via email

@loumalouomega
Copy link
Member Author

Done @philbucher

Copy link
Member

@philbucher philbucher left a comment

Choose a reason for hiding this comment

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

Take a look at codacy (minor)

If you use DOMAIN_SIZE to determine the dimension the you could add a check if the value is reasonable

kratos/processes/compute_nodal_gradient_process.cpp Outdated Show resolved Hide resolved
/***********************************************************************************/
/***********************************************************************************/

Parameters ComputeHessianSolMetricProcess::GetDefaultParameters()
Copy link
Member

Choose a reason for hiding this comment

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

const

Copy link
Member

Choose a reason for hiding this comment

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

ping

@loumalouomega
Copy link
Member Author

@philbucher Comments adressed

@loumalouomega
Copy link
Member Author

Ping @philbucher

Copy link
Member

@philbucher philbucher left a comment

Choose a reason for hiding this comment

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

some comments are not addressed

plus some more minor comments

it_node->SetValue(ANISOTROPIC_RATIO, ratio);
const auto& it_element_begin = mThisModelPart.ElementsBegin();
const auto& r_first_element_geometry = it_element_begin->GetGeometry();
const std::size_t dimension = r_first_element_geometry.WorkingSpaceDimension();
Copy link
Member

Choose a reason for hiding this comment

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

determining the dimension of the problem

VariableUtils().CheckVariableExists(mrOriginVariableDoubleList[0], nodes_array);
} else {
VariableUtils().CheckVariableExists(mrOriginVariableComponentsList[0], nodes_array);
}
for (auto& i_node : nodes_array)
KRATOS_ERROR_IF_NOT(i_node.Has(NODAL_H)) << "NODAL_H must be computed" << std::endl;
Copy link
Member

Choose a reason for hiding this comment

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

ping

mrOriginVariableComponentsList.push_back(&rVariable);

// We check the parameters
Parameters default_parameters = GetDefaultParameters();
Copy link
Member

Choose a reason for hiding this comment

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

const


// We check the parameters
Parameters default_parameters = GetDefaultParameters();
Copy link
Member

Choose a reason for hiding this comment

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

const

Copy link
Member Author

Choose a reason for hiding this comment

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

RecursivelyValidateAndAssignDefaults can not work with const Parameters

Copy link
Member

Choose a reason for hiding this comment

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

indeed, I checked, even though I think it should be
=> maybe after #58

if (dimension == 2) {
CalculateMetric<2>();
} else {
CalculateMetric<3>();
Copy link
Member

Choose a reason for hiding this comment

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

else if dim == 3

else: Error

/***********************************************************************************/
/***********************************************************************************/

Parameters ComputeHessianSolMetricProcess::GetDefaultParameters()
Copy link
Member

Choose a reason for hiding this comment

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

ping

/***********************************************************************************/
/***********************************************************************************/

Parameters ComputeHessianSolMetricProcess::GetDefaultParameters()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Parameters ComputeHessianSolMetricProcess::GetDefaultParameters()
Parameters ComputeHessianSolMetricProcess::GetDefaultParameters() const

void ComputeHessianSolMetricProcess::InitializeVariables(Parameters ThisParameters)
{
// Get default variables
Parameters default_parameters = GetDefaultParameters();
Copy link
Member

Choose a reason for hiding this comment

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

const

Copy link
Member Author

Choose a reason for hiding this comment

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

Cannot be const, (the function can be), but not the parameters. Maybe adding a new method to the Parameters (the one is still in the oldest open PR)

// Set variables
mMinSize = ThisParameters["minimal_size"].GetDouble();
mMaxSize = ThisParameters["maximal_size"].GetDouble();
mEnforceCurrent = ThisParameters["enforce_current"].GetBool();
Copy link
Member

Choose a reason for hiding this comment

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

all const

Copy link
Member Author

Choose a reason for hiding this comment

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

Member variables, cannot be const

Copy link
Member

@philbucher philbucher left a comment

Choose a reason for hiding this comment

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

looks good to me now 👍

@loumalouomega loumalouomega merged commit 12e74a8 into master Dec 30, 2018
@loumalouomega loumalouomega deleted the core/extend-gradient-process branch December 30, 2018 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants