Skip to content

Add functionality for volumetric multiscale coupling to micro-mechanics simulations #135

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

Open
wants to merge 65 commits into
base: develop
Choose a base branch
from

Conversation

IshaanDesai
Copy link
Member

@IshaanDesai IshaanDesai commented Mar 20, 2025

This PR is derived from #118 and adds functionality for volumetric coupling to micro-mechanics simulations. The functionality is primarily contributed by @kalupaika. This PR is branched from the feature branch of #118 because #118 contains code which is specific to coupling a macro-scale CalculiX simulation to many micro-scale NASMAT simulations. This PR contains the functionality:

  • Extract Gauss point coordinates of a mesh made with either C3D8 (Hex) or C3D4 (Tet) elements.
  • Get strain tensor from CalculiX and write it to preCICE.
  • Read stress tensor from preCICE and apply it in CalculiX.
  • Read stiffness matrix from preCICE and apply it in CalculiX.

The implemented functionality is tested for steady-state simulations only. To incorporate the features for transient simulations, an appropriate test case would need to be devised.

kalupaika and others added 30 commits January 17, 2024 10:34
@IshaanDesai IshaanDesai marked this pull request as ready for review April 29, 2025 12:33
Copy link
Member

@MakisH MakisH left a comment

Choose a reason for hiding this comment

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

A first round of comments after reading through most files and mostly skimming through adapter/PreciceInterface.c and linstatic_precice.c. Let's go through these files together as well.

Some of my comments are not necessarily something to act upon, just something for my own understanding.

SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c
SCCXF += getflux.f getkdeltatemp.f
SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c
SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f getc3d4elementgausspointcoords.f
Copy link
Member

Choose a reason for hiding this comment

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

Do I understand correctly that these files are completely written for the adapter, and not included in the original CalculiX source code? In that case, I wonder if they should better be under adapter/ or another new folder. What is the motivation for putting them outside?

The operations they define are specific to the adapter, right?

Comment on lines +76 to +79
for (i = istartset[setID] - 1; i < iendset[setID]; i++) {
elements[k] = ialset[i];
k++;
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need some kind of bound check for k? What is the size of elements supposed to be?

@@ -409,6 +420,18 @@ int getXloadIndexOffset(enum xloadVariable xloadVar)
}
}

void getElementStrain(int strainIdx, int numIPTotal, double *eei, double *strainData)
Copy link
Member

Choose a reason for hiding this comment

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

This function uses int for ids and sizes, but other functions use ITG. What is ITG, and is it a better-fitting type?

Same for the other two new functions.

int i, idx;
// Loop through all element and respective gauss points
for (i = 0; i < numIPTotal; i++) {
idx = i * 6 + strainIdx; //TODO: Add explanation for 6
Copy link
Member

Choose a reason for hiding this comment

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

yes, please. Two similar points below.

* @brief Gets the strain values at each Gauss point of each element
* @param strainIdx: CalculiX variable for the index of the strain values
* @param numIPTotal: CalculiX variable for the number of elements
* @param eei: CalculiX array for the element integration information
Copy link
Member

Choose a reason for hiding this comment

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

What does eei stand for? Is there a more intuitive name?
I guess this comes from some CalculiX-internal variable name, but I am still wondering.

Comment on lines +30 to +31
integer :: kon(*)
integer :: ipkon(*)
Copy link
Member

Choose a reason for hiding this comment

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

Description missing.

Same in the C3D8 file.

Copy link
Member

Choose a reason for hiding this comment

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

A summary of the preCICE-related changes would be helpful when upgrading to newer CalculiX versions.

*sim->dtheta = 1;
*sim->theta = 0;
*sim->tper = 1;
//*sim->dtheta = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Why removed?
Maybe fully remove?

@@ -315,7 +380,7 @@ void Precice_WriteCouplingData(SimulationData *sim)
sim->istartset,
sim->iendset,
sim->ipkon,
sim->lakon,
*sim->lakon,
Copy link
Member

Choose a reason for hiding this comment

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

Is lakon a pointer?
Was this wrong before, or needed now because the type changed?
Does this need to be updated anywhere else?

@@ -804,6 +1000,7 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface)
free(preciceInterface->writeData);
free(preciceInterface->elementIDs);
free(preciceInterface->faceIDs);
free(preciceInterface->nodeIDs);
Copy link
Member

Choose a reason for hiding this comment

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

How come we previously had elementIDs but not nodeIDs?

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