Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b6cba5f
updated project
Gerasimos01 Jul 31, 2022
183b02d
core multiscale capabilities successfully update for new 0.2 packages…
Gerasimos01 Jul 31, 2022
60ad901
Added tests for RveGrShOne and RveGrShMultiple. Added GmshCompositeRv…
PaschouMichail Aug 22, 2022
c10f580
copied microstructure3D defgrad class to apply changes for small stra…
Gerasimos01 Sep 2, 2022
f6ea58a
updated microstructure3D to new version. (tests updates will follow 1).
Gerasimos01 Sep 3, 2022
81a2a96
copied microstructure 3D for microstructure 2D plane stress
Gerasimos01 Sep 3, 2022
d956d9a
update microstructure2Dplanestress and copied it for microstructure2D…
Gerasimos01 Sep 3, 2022
a40281b
implemented update of microstructure shell class. supportive classes …
Gerasimos01 Sep 3, 2022
e746a76
updated more classes to new version.
Gerasimos01 Sep 5, 2022
cc17e8c
Added tests from previous version.
alexios725 Sep 5, 2022
e6ce461
Merged with Gerasimos's update.
alexios725 Sep 5, 2022
5b4ce7f
copied MicrostructureDefGrad3d to implement MicrostructureDefGrad2D c…
Gerasimos01 Sep 6, 2022
9a6643f
updated MicrostructureDefGrad2D to new version
Gerasimos01 Sep 6, 2022
11bce7e
Errors in ElasticMaterial3DTotalStrain.cs need to be fixed.
alexios725 Sep 9, 2022
7ee68ad
Errors in: ElasticMaterial3DTotalStrain, CompositeMaterialModelBuilde…
alexios725 Sep 10, 2022
74f1bea
Alexis changes to be reviewed.
Gerasimos01 Sep 11, 2022
48fedc5
fixed one of the graphene tests.
Gerasimos01 Sep 12, 2022
b0ec8ed
fixed one test (unesessary tolerance).
Gerasimos01 Sep 12, 2022
a514e8f
fixed three more test. the remaining one checks the decomposer.
Gerasimos01 Sep 13, 2022
ef8d7d0
added new nuggets (intermediate)
Gerasimos01 Nov 24, 2022
0b565a8
updated nuggets and tests passed.
Gerasimos01 Nov 24, 2022
2f06b47
tests passed with new nuggets.
Gerasimos01 Nov 24, 2022
a79be12
deleted unecessary comments
Gerasimos01 Nov 24, 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
405 changes: 405 additions & 0 deletions src/MGroup.Multiscale/Analyzers/DisplacementBvpNRNLAnalyzer.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using MGroup.MSolve.AnalysisWorkflow;
using MGroup.MSolve.Discretization;
using MGroup.MSolve.Discretization.BoundaryConditions;
using MGroup.MSolve.Discretization.Dofs;
using MGroup.MSolve.Discretization.Entities;
using MGroup.MSolve.Discretization.Providers;
using MGroup.MSolve.Solution.LinearSystem;
using MGroup.MSolve.Solution.AlgebraicModel;
using System.Linq;
using MGroup.Solvers.AlgebraicModel;
using MGroup.LinearAlgebra.Matrices;
using MGroup.Constitutive.Structural;
using MGroup.LinearAlgebra.Vectors;
using MGroup.Solvers.DofOrdering;
using MGroup.Solvers;

namespace MiMsolve.intermediateCodeDevelopmentClasses
{
/// <summary>
/// Assembles the equivalent contribution of imposed displacements in a bvp with non zero initial conditions.
/// Authors: Gerasimos Sotiropoulos
/// </summary>
public class ElementEquivalentContributionsProvider : IElementVectorProvider
{
private readonly IAlgebraicModel algebraicModel;
private IElementMatrixProvider elementProvider;
private readonly ISubdomain subdomain;
private readonly IModel model;
private ActiveDofs ActiveDofs;
private ISubdomainFreeDofOrdering subdomainFreeDofORdering;
private IntDofTable freeDofs;
private Dictionary<int, INode> boundaryNodes;
private Dictionary<int, Dictionary<IDofType, double>> initialConvergedBoundaryDisplacements;
private Dictionary<int, Dictionary<IDofType, double>> totalBoundaryDisplacements;
private int nIncrement;
private int totalIncrements;
/// <summary>
/// ELEMENT provider tha perastei profanws o ElementStructuralStiffnessProvider elementProvider = new ElementStructuralStiffnessProvider();
/// kai subdomain prosoxh sta ID idia me ta linearsystems
/// </summary>
/// <param name="subdomain"></param>
/// <param name="elementProvider"></param>


public ElementEquivalentContributionsProvider(IAlgebraicModel algebraicModel, IElementMatrixProvider elementProvider, Dictionary<int, INode> boundaryNodes,
Dictionary<int, Dictionary<IDofType, double>> initialConvergedBoundaryDisplacements, Dictionary<int, Dictionary<IDofType, double>> totalBoundaryDisplacements,
int nIncrement, int totalIncrements)
{
this.algebraicModel = algebraicModel;
this.elementProvider = elementProvider;
ActiveDofs = new ActiveDofs();
ActiveDofs.AddDof(StructuralDof.TranslationX);
ActiveDofs.AddDof(StructuralDof.TranslationY);
ActiveDofs.AddDof(StructuralDof.TranslationZ);
ActiveDofs.AddDof(StructuralDof.RotationX);
ActiveDofs.AddDof(StructuralDof.RotationY);
ActiveDofs.AddDof(StructuralDof.RotationZ);
this.boundaryNodes = boundaryNodes;
this.initialConvergedBoundaryDisplacements = initialConvergedBoundaryDisplacements;
this.totalBoundaryDisplacements = totalBoundaryDisplacements;
this.nIncrement = nIncrement;
this.totalIncrements = totalIncrements;

}

public double[] CalcVector(IElementType element)
{
var elementDOFTypes = element.DofEnumerator.GetDofTypesForMatrixAssembly(element);
var matrixAssemblyNodes = element.DofEnumerator.GetNodesForMatrixAssembly(element);
var totalElementDofs = elementDOFTypes.Select(x => x.Count()).ToList().Sum(); //TODO if element exei bondary nodes

double[] uStep_values_orZero_for_free = new double[totalElementDofs];
bool boundaryNodeFound = false;
int iElementMatrixColumn = 0;
for (int j = 0; j < elementDOFTypes.Count; j++)
{
INode nodeColumn = matrixAssemblyNodes[j];


int nodalDofsNumber = elementDOFTypes[j].Count; //TODOGerasimos elegxos oti edw oi ginetai prosvash apo 0:1:megethos
if (boundaryNodes.ContainsKey(nodeColumn.ID))
{
boundaryNodeFound = true;


double[] element_Kfp_triplette = new double[nodalDofsNumber]; //nodalDofsNumber: giati oxi scaleTransitions.PrescribedDofsPerNode()? Dioti tou ta pairname ola(triplette) kai dialegei to


Dictionary<IDofType, double> nodalConvergedDisplacements = initialConvergedBoundaryDisplacements[nodeColumn.ID];
Dictionary<IDofType, double> nodalTotalDisplacements = totalBoundaryDisplacements[nodeColumn.ID];
//double[] uStep_values_orZero_for_free = new double[nodalDofsNumber];

int positionOfDof = 0;
foreach (IDofType doftype1 in elementDOFTypes[j])
{
if (nodalConvergedDisplacements.ContainsKey(doftype1))
{
uStep_values_orZero_for_free[iElementMatrixColumn + positionOfDof] = (nodalTotalDisplacements[doftype1] - nodalConvergedDisplacements[doftype1]) * (nIncrement / (double)totalIncrements);
// TODO: this can be done faster: create a dictionary<...,dictionary> with the difference of the two values and use that and precalculate coefficient for scaling
}
positionOfDof += 1;
}





}
iElementMatrixColumn += nodalDofsNumber;

}

if (boundaryNodeFound)
{
IMatrix ElementK = elementProvider.Matrix(element);
Vector uStep = Vector.CreateFromArray(uStep_values_orZero_for_free);
var elementContribution = ElementK.Multiply(uStep, false);
var elementContributionCheck = new double[totalElementDofs];
for (int j1 = 0; j1 < totalElementDofs; j1++)
{
for (int j2 = 0; j2 < totalElementDofs; j2++)
{
elementContributionCheck[j1] += ElementK[j1, j2] * uStep[j2];
}
}
return elementContribution.CopyToArray();
}
else
{
return new double[totalElementDofs];
}
}


}
}
85 changes: 0 additions & 85 deletions src/MGroup.Multiscale/Analyzers/HomogenizationAnalyzer.cs

This file was deleted.

164 changes: 82 additions & 82 deletions src/MGroup.Multiscale/Analyzers/MSParentAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@
using System;
using System.Collections.Generic;
using MGroup.Analyzers.Interfaces;
using MGroup.LinearAlgebra.Vectors;
using MGroup.MSolve.Discretization.Interfaces;
using MGroup.MSolve.Logging.Interfaces;
using MGroup.Solvers;
using MGroup.Solvers.LinearSystems;

namespace MGroup.Multiscale.Analyzers
{
/// <summary>
/// Parent Analyzer for nonlinear static problems assosiated with a microstructure bvp handled by MicrostructureBvpNRNLAnalyzer
/// Authors: Gerasimos Sotiropoulos
/// </summary>
public class MSParentAnalyzer : INonLinearParentAnalyzer
{
private readonly IReadOnlyDictionary<int, ILinearSystem> linearSystems;
private readonly IModel model;
private readonly IStaticProvider provider;
private readonly ISolver solver;
private bool firstInitialization;

public MSParentAnalyzer(IModel model, ISolver solver, IStaticProvider provider,
IChildAnalyzer childAnalyzer)
{
this.model = model;
this.linearSystems = solver.LinearSystems;
this.solver = solver;
this.provider = provider;
this.ChildAnalyzer = childAnalyzer;
this.ChildAnalyzer.ParentAnalyzer = this;
}

public Dictionary<int, IAnalyzerLog[]> Logs { get; } = new Dictionary<int, IAnalyzerLog[]>();

public IChildAnalyzer ChildAnalyzer { get; }

public void BuildMatrices()
{
foreach (ILinearSystem linearSystem in linearSystems.Values)
{
linearSystem.Matrix = provider.CalculateMatrix(linearSystem.Subdomain);
}
}

public IVector GetOtherRhsComponents(ILinearSystem linearSystem, IVector currentSolution)
{
//TODO: use a ZeroVector class that avoid doing useless operations or refactor this method. E.g. let this method
// alter the child analyzer's rhs vector, instead of the opposite (which is currently done).
return linearSystem.CreateZeroVector();
}

public void Initialize(bool isFirstAnalysis = true)
{

if (ChildAnalyzer == null) throw new InvalidOperationException("Static analyzer must contain an embedded analyzer.");
//InitalizeMatrices();

//model.ConnectDataStructures();
//solver.OrderDofsAndClearLinearSystems(); //TODO MS Since orderdofs is called here it cannot be called twice (hence in subdomainmicrobase) so modify
//solver.ResetSubdomainForcesVector();

//model.AssignLoads(); //mhdenizei ta subdomain.forces ean exoume epivalei fortio afou tous pernaei ta fortia

//TODO: this should be done elsewhere. It makes sense to assign the RHS vector when the stiffness matrix is assigned
foreach (ILinearSystem linearSystem in linearSystems.Values)
{
linearSystem.RhsVector = linearSystem.Subdomain.Forces;
}

ChildAnalyzer.Initialize(isFirstAnalysis);
}

public void Solve()
{
if (ChildAnalyzer == null) throw new InvalidOperationException("Static analyzer must contain an embedded analyzer.");
BuildMatrices(); //TODO: this should be called by the class that calls model.AssignLoads() and before it.
ChildAnalyzer.Solve();
}
}
}
using System;
using System.Collections.Generic;
using MGroup.LinearAlgebra.Vectors;
using MGroup.MSolve.AnalysisWorkflow;
using MGroup.MSolve.AnalysisWorkflow.Logging;
using MGroup.MSolve.AnalysisWorkflow.Providers;
using MGroup.MSolve.DataStructures;
using MGroup.MSolve.Discretization;
using MGroup.MSolve.Discretization.Entities;
using MGroup.MSolve.Solution;
using MGroup.MSolve.Solution.AlgebraicModel;
using MGroup.MSolve.Solution.LinearSystem;
namespace MiMsolve.multiScaleSupportiveClasses
{
/// <summary>
/// Parent Analyzer for nonlinear static problems assosiated with a microstructure bvp handled by MicrostructureBvpNRNLAnalyzer
/// Authors: Gerasimos Sotiropoulos
/// </summary>
public class MSParentAnalyzer : INonLinearParentAnalyzer
{
//private readonly IReadOnlyDictionary<int, ILinearSystem> linearSystems;
private readonly IModel model;
private readonly INonTransientAnalysisProvider provider;
private readonly ISolver solver;
private bool firstInitialization;
private readonly IAlgebraicModel algebraicModel;
public MSParentAnalyzer(IModel model, IAlgebraicModel algebraicModel, ISolver solver, INonTransientAnalysisProvider provider,
IChildAnalyzer childAnalyzer)
{
this.model = model;
this.algebraicModel = algebraicModel;
this.solver = solver;
this.provider = provider;
this.ChildAnalyzer = childAnalyzer;
this.ChildAnalyzer.ParentAnalyzer = this;
}
public IAnalysisWorkflowLog[] Logs { get; set; }
public IChildAnalyzer ChildAnalyzer { get; }
public IGlobalVector CurrentAnalysisResult => throw new NotImplementedException();
public GenericAnalyzerState CurrentState { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public void BuildMatrices()
{
provider.CalculateMatrix();
}
public IGlobalVector GetOtherRhsComponents(IGlobalVector currentSolution)
{
return algebraicModel.CreateZeroVector();
}
public void Initialize(bool isFirstAnalysis = true)
{
if (ChildAnalyzer == null) throw new InvalidOperationException("Static analyzer must contain an embedded analyzer.");
ChildAnalyzer.Initialize(isFirstAnalysis);
}
public void Solve()
{
if (ChildAnalyzer == null) throw new InvalidOperationException("Static analyzer must contain an embedded analyzer.");
BuildMatrices(); //TODO: this should be called by the class that calls model.AssignLoads() and before it.
ChildAnalyzer.Solve();
}
public GenericAnalyzerState CreateState() => throw new NotImplementedException();
IHaveState ICreateState.CreateState() => throw new NotImplementedException();
}
}
Loading