forked from ParkSuMin/MemMAPR-MKE
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b80340998 | |||
| 5b2331445c | |||
| e3c7b88dfb | |||
| 64cb04388a | |||
| b07c9e6cea | |||
| 1585c76980 | |||
| 1fc2925f8f | |||
| 8957f65064 | |||
| cac280deb1 | |||
| b8bc3f705a |
13
.gitignore
vendored
13
.gitignore
vendored
@@ -636,14 +636,7 @@ FodyWeavers.xsd
|
|||||||
*.msix
|
*.msix
|
||||||
*.msm
|
*.msm
|
||||||
*.msp
|
*.msp
|
||||||
|
|
||||||
*.txt
|
*.txt
|
||||||
|
!CMakeLists.txt
|
||||||
# Visual studio files
|
*.png
|
||||||
*.vcxproj
|
|
||||||
*.vcxproj.filters
|
|
||||||
*.sln
|
|
||||||
*.vcxproj.user
|
|
||||||
packages.config
|
|
||||||
|
|
||||||
# Cmake
|
|
||||||
!CMakeLists.txt
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
project(MemMAPR-MKE CXX)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
set(SRC MemMAPR-MKE.cpp Solver.cpp)
|
|
||||||
|
|
||||||
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
|
|
||||||
add_executable(mimapr ${SRC})
|
|
||||||
target_link_libraries (mimapr Eigen3::Eigen)
|
|
||||||
target_compile_options(mimapr PRIVATE -Wall -Wextra -Wpedantic)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#include "Header.h"
|
|
||||||
#include "Solver.h"
|
|
||||||
#include <Eigen/Dense>
|
|
||||||
using namespace Eigen;
|
|
||||||
int main() {
|
|
||||||
Solver slv(5., 4., 0., 1., 30, 0, 10);
|
|
||||||
std::cout << "Linear element:";
|
|
||||||
slv.Execute_Linear(0, 5);
|
|
||||||
std::cout << "\nCubic element:";
|
|
||||||
slv.Execute_Cubic(0, 5);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
37
MemMAPR-MKE.sln
Normal file
37
MemMAPR-MKE.sln
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.14.36310.24
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemMAPR-MKE", "MemMAPR-MKE.vcxproj", "{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
DEBUG_THIRD|x64 = DEBUG_THIRD|x64
|
||||||
|
DEBUG_THIRD|x86 = DEBUG_THIRD|x86
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.DEBUG_THIRD|x64.ActiveCfg = DEBUG_FIRST|x64
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.DEBUG_THIRD|x64.Build.0 = DEBUG_FIRST|x64
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.DEBUG_THIRD|x86.ActiveCfg = DEBUG_FIRST|Win32
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.DEBUG_THIRD|x86.Build.0 = DEBUG_FIRST|Win32
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Release|x64.Build.0 = Release|x64
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{5D2C9737-E669-4AF1-9B8C-4339EF6E4EB0}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {F7275EE5-C713-4706-94E6-F43DF9702869}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
205
MemMAPR-MKE.vcxproj
Normal file
205
MemMAPR-MKE.vcxproj
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="DEBUG_FIRST|Win32">
|
||||||
|
<Configuration>DEBUG_FIRST</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="DEBUG_FIRST|x64">
|
||||||
|
<Configuration>DEBUG_FIRST</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>17.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{5d2c9737-e669-4af1-9b8c-4339ef6e4eb0}</ProjectGuid>
|
||||||
|
<RootNamespace>MemMAPRMKE</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG_FIRST|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG_FIRST|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG_FIRST|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG_FIRST|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG_FIRST|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>include/</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG_FIRST|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>DEBUG;_CONSOLE;THIRD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>include/</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>include/</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\MemMAPR-MKE.cpp" />
|
||||||
|
<ClCompile Include="src\Solver.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="include\Header.h" />
|
||||||
|
<ClInclude Include="include\Solver.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="packages\Eigen.3.3.3\build\native\Eigen.targets" Condition="Exists('packages\Eigen.3.3.3\build\native\Eigen.targets')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('packages\Eigen.3.3.3\build\native\Eigen.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Eigen.3.3.3\build\native\Eigen.targets'))" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
39
MemMAPR-MKE.vcxproj.filters
Normal file
39
MemMAPR-MKE.vcxproj.filters
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Исходные файлы">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы заголовков">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы ресурсов">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Solver">
|
||||||
|
<UniqueIdentifier>{3be6c970-16cc-463a-a3d5-22a26a8bff54}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\Solver.cpp">
|
||||||
|
<Filter>Solver</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\MemMAPR-MKE.cpp">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="include\Solver.h">
|
||||||
|
<Filter>Solver</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\Header.h">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
4
MemMAPR-MKE.vcxproj.user
Normal file
4
MemMAPR-MKE.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
</Project>
|
||||||
160
Solver.cpp
160
Solver.cpp
@@ -1,160 +0,0 @@
|
|||||||
#include "Header.h"
|
|
||||||
#include <Eigen/Dense>
|
|
||||||
using namespace Eigen;
|
|
||||||
|
|
||||||
Solver::Solver(double _A, double _B, double _C, double _D, int _N, int _l, int _u) {
|
|
||||||
A = _A, B = _B, C = _C, D = _D, N = _N;
|
|
||||||
upper = _u, lower = _l;
|
|
||||||
L = (double)(upper - lower) / N;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Solver::Execute_Linear(double val1, double val2) {
|
|
||||||
|
|
||||||
// Локальная матрица жёсткости
|
|
||||||
MatrixXd local = MatrixXd::Zero(2, 2);
|
|
||||||
|
|
||||||
// Локальный вектор нагрузки
|
|
||||||
VectorXd local_load(2);
|
|
||||||
|
|
||||||
local(0, 0) = -A / L - B / 2. + C * L / 3.;
|
|
||||||
local(0, 1) = A / L + B / 2. + C * L / 6.;
|
|
||||||
local(1, 0) = A / L - B / 2. + C * L / 6.;
|
|
||||||
local(1, 1) = -A / L + B / 2. + C * L / 3.;
|
|
||||||
|
|
||||||
local_load(0) = -D * L / 2.;
|
|
||||||
local_load(1) = -D * L / 2.;
|
|
||||||
|
|
||||||
// Глобальная матрица жёсткости
|
|
||||||
MatrixXd ansamb = MatrixXd::Zero(N + 1, N + 1);
|
|
||||||
|
|
||||||
// Глобальный вектор нагрузок
|
|
||||||
VectorXd global_load = VectorXd::Zero(N + 1);
|
|
||||||
|
|
||||||
// Ансамблирование
|
|
||||||
for (int elem = 0; elem < N; ++elem) {
|
|
||||||
int node_i = elem;
|
|
||||||
int node_j = elem + 1;
|
|
||||||
|
|
||||||
ansamb(node_i, node_i) += local(0, 0);
|
|
||||||
ansamb(node_i, node_j) += local(0, 1);
|
|
||||||
ansamb(node_j, node_i) += local(1, 0);
|
|
||||||
ansamb(node_j, node_j) += local(1, 1);
|
|
||||||
|
|
||||||
global_load(node_i) += local_load(0);
|
|
||||||
global_load(node_j) += local_load(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
std::cout << std::endl << "Before:" << std::endl;
|
|
||||||
std::cout << "Ansamb matrix:\n" << ansamb << std::endl;
|
|
||||||
std::cout << "Ansamb load vector:\n" << global_load << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Граничные условия
|
|
||||||
double u_right = val2;
|
|
||||||
ansamb.row(0).setZero();
|
|
||||||
ansamb.row(N).setZero();
|
|
||||||
|
|
||||||
ansamb(0, 0) = L + 1;
|
|
||||||
ansamb(0, 1) = -1;
|
|
||||||
global_load(0) = 0;
|
|
||||||
|
|
||||||
ansamb(N, N) = 1;
|
|
||||||
global_load(N) = u_right;
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
std::cout << "\nAfter:" << std::endl;
|
|
||||||
std::cout << "Modified matrix:\n" << ansamb << std::endl;
|
|
||||||
std::cout << "Modified load vector:\n" << global_load << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Решение системы
|
|
||||||
VectorXd solution = ansamb.fullPivLu().solve(global_load);
|
|
||||||
std::cout << "\nSolution:" << std::endl;
|
|
||||||
std::cout << solution << std::endl;
|
|
||||||
|
|
||||||
std::ofstream file("matrix_linear_" + std::to_string(N) + ".txt");
|
|
||||||
for (int i = 0; i < solution.size(); i++) {
|
|
||||||
file << solution(i) << ' ';
|
|
||||||
}
|
|
||||||
file << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: переделать под себя
|
|
||||||
void Solver::Execute_Cubic(double val1, double val2) {
|
|
||||||
|
|
||||||
int mat_dim = 1 + N * 3;
|
|
||||||
|
|
||||||
// Глобальная матрица жёсткости
|
|
||||||
Eigen::MatrixXd Amat(mat_dim, mat_dim);
|
|
||||||
|
|
||||||
// Глобальный вектор нагрузок
|
|
||||||
Eigen::VectorXd b(mat_dim);
|
|
||||||
Amat.setZero();
|
|
||||||
b.setZero();
|
|
||||||
|
|
||||||
// Assemble matrix
|
|
||||||
for (int i = 0; i < mat_dim - 3; i += 3) {
|
|
||||||
Amat(i, i + 0) -= A * 37.0 / 10.0 / L;
|
|
||||||
Amat(i, i + 1) -= A * (-189.0) / 40.0 / L;
|
|
||||||
Amat(i, i + 2) -= A * 27.0 / 20.0 / L;
|
|
||||||
Amat(i, i + 3) -= A * (-13.0) / 40.0 / L;
|
|
||||||
Amat(i + 1, i + 0) -= A * (-189.0) / 40.0 / L;
|
|
||||||
Amat(i + 1, i + 1) -= A * 54.0 / 5.0 / L;
|
|
||||||
Amat(i + 1, i + 2) -= A * (-297.0) / 40.0 / L;
|
|
||||||
Amat(i + 1, i + 3) -= A * 27.0 / 20.0 / L;
|
|
||||||
Amat(i + 2, i + 0) -= A * 27.0 / 20.0 / L;
|
|
||||||
Amat(i + 2, i + 1) -= A * (-297.0) / 40.0 / L;
|
|
||||||
Amat(i + 2, i + 2) -= A * 54.0 / 5.0 / L;
|
|
||||||
Amat(i + 2, i + 3) -= A * (-189.0) / 40.0 / L;
|
|
||||||
Amat(i + 3, i + 0) -= A * (-13.0) / 40.0 / L;
|
|
||||||
Amat(i + 3, i + 1) -= A * 27.0 / 20.0 / L;
|
|
||||||
Amat(i + 3, i + 2) -= A * (-189.0) / 40.0 / L;
|
|
||||||
Amat(i + 3, i + 3) -= A * 37.0 / 10.0 / L;
|
|
||||||
|
|
||||||
Amat(i + 0, i + 0) += B * (-1.0) / 2.0;
|
|
||||||
Amat(i + 0, i + 1) += B * 57.0 / 80.0;
|
|
||||||
Amat(i + 0, i + 2) += B * (-3.0) / 10.0;
|
|
||||||
Amat(i + 0, i + 3) += B * 7.0 / 80.0;
|
|
||||||
Amat(i + 1, i + 0) += B * (-57.0) / 80.0;
|
|
||||||
|
|
||||||
Amat(i + 1, i + 2) += B * 81.0 / 80.0;
|
|
||||||
Amat(i + 1, i + 3) += B * (-3.0) / 10;
|
|
||||||
Amat(i + 2, i + 0) += B * 3.0 / 10.0;
|
|
||||||
Amat(i + 2, i + 1) += B * (-81.0) / 80.0;
|
|
||||||
|
|
||||||
Amat(i + 2, i + 3) += B * 57.0 / 80.0;
|
|
||||||
Amat(i + 3, i + 0) += B * (-7.0) / 80.0;
|
|
||||||
Amat(i + 3, i + 1) += B * 3.0 / 10.0;
|
|
||||||
Amat(i + 3, i + 2) += B * (-57.0) / 80.0;
|
|
||||||
Amat(i + 3, i + 3) += B * 1.0 / 2.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// AssembLe vector
|
|
||||||
for (int i = 0; i < mat_dim - 3; i += 3) {
|
|
||||||
b(i) -= D * L / 8.0;
|
|
||||||
b(i + 1) -= D * 3.0 * L / 8.0;
|
|
||||||
b(i + 2) -= D * 3.0 * L / 8.0;
|
|
||||||
b(i + 3) -= D * L / 8.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Amat.row(0).setZero();
|
|
||||||
Amat(0, 0) = L / 3.0 + 1;
|
|
||||||
Amat(0, 1) = -1;
|
|
||||||
b(0) = 0;
|
|
||||||
|
|
||||||
Amat.row(mat_dim - 1).setZero();
|
|
||||||
Amat(mat_dim - 1, mat_dim - 1) = 1;
|
|
||||||
b(mat_dim - 1) = val2;
|
|
||||||
|
|
||||||
// Решение системы
|
|
||||||
VectorXd solution = Amat.fullPivLu().solve(b);
|
|
||||||
std::cout << "\nSolution:" << std::endl;
|
|
||||||
std::cout << solution << std::endl;
|
|
||||||
|
|
||||||
std::ofstream file("matrix_cubic_" + std::to_string(N) + ".txt");
|
|
||||||
for (int i = 0; i < solution.size(); i++) {
|
|
||||||
file << solution(i) << ' ';
|
|
||||||
}
|
|
||||||
file << std::endl;
|
|
||||||
}
|
|
||||||
17
Solver.h
17
Solver.h
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class Solver {
|
|
||||||
private:
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><>
|
|
||||||
double A, B, C, D;
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
double L;
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
int N;
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
|
||||||
int upper, lower;
|
|
||||||
public:
|
|
||||||
Solver(double _A, double _B, double _C, double _D, int _N, int _l, int _u);
|
|
||||||
void Execute_Linear(double value_1, double value_2);
|
|
||||||
void Execute_Cubic(double value_1, double value_2);
|
|
||||||
};
|
|
||||||
@@ -8,6 +8,34 @@
|
|||||||
"# Solution of second-order linear ordinary differential equation"
|
"# Solution of second-order linear ordinary differential equation"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "a4b21c72",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Input vars"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6653253d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"N = 20\n",
|
||||||
|
"linear_file = f\"matrix_linear_{N}.txt\"\n",
|
||||||
|
"cubic_file = f\"matrix_cubic_{N}.txt\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "781047cc",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## System cells"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -37,7 +65,7 @@
|
|||||||
"id": "8af07a56",
|
"id": "8af07a56",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## Solution of $5u'' + 4u' + 1 = 0, u'(0) = u(0), u(10) = 5$"
|
"### Solution of $5u'' + 4u' + 1 = 0, u'(0) = u(0), u(10) = 5$"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -56,7 +84,7 @@
|
|||||||
"id": "efac514a",
|
"id": "efac514a",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## Linear element"
|
"### Linear element"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -74,12 +102,12 @@
|
|||||||
" y = np.fromstring(data_str, sep=' ')\n",
|
" y = np.fromstring(data_str, sep=' ')\n",
|
||||||
" y_real = u(x)\n",
|
" y_real = u(x)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" plt.plot(x, y, label=\"Linear element solution\", color='red')\n",
|
" plt.plot(x, y, label=\"Linear element solution\", color='blue')\n",
|
||||||
" plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n",
|
" plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n",
|
||||||
" plt.title(f\"Linear element, elements = {elements}\")\n",
|
" plt.title(f\"Linear element, elements = {elements}\")\n",
|
||||||
" plt.grid(True)\n",
|
" plt.grid(True)\n",
|
||||||
" plt.xlabel(\"X\")\n",
|
" plt.xlabel(\"x\")\n",
|
||||||
" plt.ylabel(\"Y\")\n",
|
" plt.ylabel(\"u(x)\")\n",
|
||||||
" plt.legend()\n",
|
" plt.legend()\n",
|
||||||
" plt.savefig(f\"linear_{elements}.png\", dpi=300)\n",
|
" plt.savefig(f\"linear_{elements}.png\", dpi=300)\n",
|
||||||
" plt.show()\n",
|
" plt.show()\n",
|
||||||
@@ -92,7 +120,7 @@
|
|||||||
"id": "d9a38740",
|
"id": "d9a38740",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## Cubic element"
|
"### Cubic element"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -110,11 +138,11 @@
|
|||||||
" y = np.fromstring(data_str, sep=' ')\n",
|
" y = np.fromstring(data_str, sep=' ')\n",
|
||||||
" y_real = u(x)\n",
|
" y_real = u(x)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" plt.plot(x, y, label=\"Cubic element solution\", color=\"green\")\n",
|
" plt.plot(x, y, label=\"Cubic element solution\", color=\"red\")\n",
|
||||||
" plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n",
|
" plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n",
|
||||||
" plt.title(f\"Cubic element, elements = {elements} \")\n",
|
" plt.title(f\"Cubic element, elements = {elements} \")\n",
|
||||||
" plt.xlabel(\"X\")\n",
|
" plt.xlabel(\"x\")\n",
|
||||||
" plt.ylabel(\"Y\")\n",
|
" plt.ylabel(\"u(x)\")\n",
|
||||||
" plt.grid(True)\n",
|
" plt.grid(True)\n",
|
||||||
" plt.legend()\n",
|
" plt.legend()\n",
|
||||||
" plt.savefig(f\"cubic_{elements}.png\", dpi=300)\n",
|
" plt.savefig(f\"cubic_{elements}.png\", dpi=300)\n",
|
||||||
@@ -138,9 +166,8 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"N = 20\n",
|
"show_plot_linear(linear_file, N)\n",
|
||||||
"show_plot_linear(\"matrix_linear.txt\", N)\n",
|
"show_plot_cubic(cubic_file, N)"
|
||||||
"show_plot_cubic(\"matrix_cubic.txt\", N)"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -154,7 +181,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "e0e9266d",
|
"id": "31de1104",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -162,8 +189,16 @@
|
|||||||
" with open(filename, 'r') as file:\n",
|
" with open(filename, 'r') as file:\n",
|
||||||
" content = file.read().strip()\n",
|
" content = file.read().strip()\n",
|
||||||
" data = np.array([float(x) for x in content.split()])\n",
|
" data = np.array([float(x) for x in content.split()])\n",
|
||||||
" return data\n",
|
" return data"
|
||||||
"\n",
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "e0e9266d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
"def show_error(program_file: str, analytical_file: str):\n",
|
"def show_error(program_file: str, analytical_file: str):\n",
|
||||||
" # Считывание данных из файлов\n",
|
" # Считывание данных из файлов\n",
|
||||||
" real = read_data_from_file(analytical_file)\n",
|
" real = read_data_from_file(analytical_file)\n",
|
||||||
@@ -192,13 +227,14 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"show_error(\"matrix_linear.txt\", \"linear_real_y_20.txt\")"
|
"show_error(linear_file, f\"linear_real_y_{N}.txt\")\n",
|
||||||
|
"show_error(cubic_file, f\"cubic_real_y_{N}.txt\")"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": ".venv",
|
"display_name": "Python 3",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
|
|||||||
31
include/Solver.h
Normal file
31
include/Solver.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Особенности MSVC
|
||||||
|
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <experimental/filesystem>
|
||||||
|
using namespace std;
|
||||||
|
using namespace std::experimental::filesystem;
|
||||||
|
|
||||||
|
class Solver {
|
||||||
|
private:
|
||||||
|
// Коэффициенты в ДУ
|
||||||
|
double A, B, C, D;
|
||||||
|
// Длина конечного элемента
|
||||||
|
double L;
|
||||||
|
// Количество конечных элементов
|
||||||
|
int N;
|
||||||
|
// Границы частного решения ДУ
|
||||||
|
int upper, lower;
|
||||||
|
public:
|
||||||
|
Solver(double _A, double _B, double _C, double _D, int _N, int _l, int _u);
|
||||||
|
void Execute_Linear(double value_1, double value_2);
|
||||||
|
void Execute_Cubic(double value_1, double value_2);
|
||||||
|
|
||||||
|
bool check_path(string path) {
|
||||||
|
return exists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void make_path(string path) {
|
||||||
|
create_directory(path);
|
||||||
|
}
|
||||||
|
};
|
||||||
4
packages.config
Normal file
4
packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Eigen" version="3.3.3" targetFramework="native" />
|
||||||
|
</packages>
|
||||||
18
src/MemMAPR-MKE.cpp
Normal file
18
src/MemMAPR-MKE.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "Solver.h"
|
||||||
|
#include "Header.h"
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
#define A 5.
|
||||||
|
#define B 4.
|
||||||
|
#define C 0.
|
||||||
|
#define D 1.
|
||||||
|
|
||||||
|
using namespace Eigen;
|
||||||
|
int main() {
|
||||||
|
std::cout << A << "u''" << " + " << B << "u'" << "+ " << C << "u + " << D << " = 0" << std::endl;
|
||||||
|
Solver slv(A, B, C, D, 20, 0, 10);
|
||||||
|
std::cout << "Linear element:";
|
||||||
|
slv.Execute_Linear(0, 5);
|
||||||
|
std::cout << "\nCubic element:";
|
||||||
|
slv.Execute_Cubic(0, 5);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
186
src/Solver.cpp
Normal file
186
src/Solver.cpp
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
#include "Header.h"
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
using namespace Eigen;
|
||||||
|
|
||||||
|
Solver::Solver(double _A, double _B, double _C, double _D, int _N, int _l, int _u) {
|
||||||
|
if (_N < 1)
|
||||||
|
throw std::runtime_error("N CAN BE OVER THAN 1!");
|
||||||
|
|
||||||
|
A = _A, B = _B, C = _C, D = _D, N = _N;
|
||||||
|
upper = _u, lower = _l;
|
||||||
|
L = (double)(upper - lower) / N;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Solver::Execute_Linear(double val1, double val2) {
|
||||||
|
|
||||||
|
// Локальная матрица жёсткости
|
||||||
|
MatrixXd local = MatrixXd::Zero(2, 2);
|
||||||
|
|
||||||
|
// Локальный вектор нагрузки
|
||||||
|
VectorXd local_load(2);
|
||||||
|
|
||||||
|
local(0, 0) = -A / L - B / 2. + C * L / 2.;
|
||||||
|
local(0, 1) = A / L + B / 2. + C * L / 2.;
|
||||||
|
local(1, 0) = A / L - B / 2. + C * L / 2.;
|
||||||
|
local(1, 1) = -A / L + B / 2. + C * L / 2.;
|
||||||
|
|
||||||
|
local_load(0) = -D * L / 2.;
|
||||||
|
local_load(1) = -D * L / 2.;
|
||||||
|
|
||||||
|
// Глобальная матрица жёсткости
|
||||||
|
MatrixXd ansamb = MatrixXd::Zero(N + 2, N + 2);
|
||||||
|
|
||||||
|
// Глобальный вектор нагрузок
|
||||||
|
VectorXd global_load = VectorXd::Zero(N + 2);
|
||||||
|
|
||||||
|
// Ансамблирование (с учётом смещения на 1)
|
||||||
|
for (int elem = 0; elem < N; ++elem) {
|
||||||
|
int node_i = elem + 1;
|
||||||
|
int node_j = elem + 2;
|
||||||
|
|
||||||
|
ansamb(node_i, node_i) += local(0, 0);
|
||||||
|
ansamb(node_i, node_j) += local(0, 1);
|
||||||
|
ansamb(node_j, node_i) += local(1, 0);
|
||||||
|
ansamb(node_j, node_j) += local(1, 1);
|
||||||
|
|
||||||
|
global_load(node_i) += local_load(0);
|
||||||
|
global_load(node_j) += local_load(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
std::cout << std::endl << "Before:" << std::endl;
|
||||||
|
std::cout << "Ansamb matrix:\n" << ansamb << std::endl;
|
||||||
|
std::cout << "Ansamb load vector:\n" << global_load << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Boundary conditions
|
||||||
|
double u_right = val2;
|
||||||
|
|
||||||
|
// 3rd type of boundary condition
|
||||||
|
ansamb.row(0).setZero();
|
||||||
|
ansamb(0, 0) = 1;
|
||||||
|
ansamb(0, 1) = -1;
|
||||||
|
global_load(0) = 0;
|
||||||
|
ansamb(1, 1) -= A;
|
||||||
|
|
||||||
|
// 1st type of boundary condition
|
||||||
|
for (int i = 0; i < global_load.size(); ++i) {
|
||||||
|
global_load(i) = global_load(i) - u_right * ansamb(i, N + 1);
|
||||||
|
}
|
||||||
|
ansamb.row(N + 1).setZero();
|
||||||
|
ansamb.col(N + 1).setZero();
|
||||||
|
ansamb(N + 1, N + 1) = 1;
|
||||||
|
global_load(N + 1) = u_right;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
std::cout << "\nAfter:" << std::endl;
|
||||||
|
std::cout << "Modified matrix:\n" << ansamb << std::endl;
|
||||||
|
std::cout << "Modified load vector:\n" << global_load << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Решение системы
|
||||||
|
VectorXd solution = ansamb.fullPivLu().solve(global_load);
|
||||||
|
std::cout << "\nSolution:" << std::endl;
|
||||||
|
std::cout << solution << std::endl;
|
||||||
|
|
||||||
|
std::ofstream file("matrix_linear_" + std::to_string(N) + ".txt");
|
||||||
|
for (int i = 1; i < solution.size(); i++) {
|
||||||
|
file << solution(i) << ' ';
|
||||||
|
}
|
||||||
|
file << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Solver::Execute_Cubic(double val1, double val2) {
|
||||||
|
|
||||||
|
int mat_dim = N * 3 + 2; // +2 для граничных узлов, как в линейном случае
|
||||||
|
|
||||||
|
// Локальная матрица жёсткости
|
||||||
|
MatrixXd local = MatrixXd::Zero(4, 4);
|
||||||
|
|
||||||
|
// Локальный вектор нагрузки
|
||||||
|
VectorXd local_load(4);
|
||||||
|
|
||||||
|
// Формирование локальной матрицы жёсткости
|
||||||
|
local(0, 0) = -A * 37.0 / 10.0 / L + B * (-1.0) / 2.0 + C * 8. * L / 105.;
|
||||||
|
local(0, 1) = -A * (-189.0) / 40.0 / L + B * 57.0 / 80.0 + C * 33. * L / 560.;
|
||||||
|
local(0, 2) = -A * 27.0 / 20.0 / L + B * (-3.0) / 10.0 - C * 3. * L / 140.;
|
||||||
|
local(0, 3) = -A * (-13.0) / 40.0 / L + B * 7.0 / 80.0 + C * 19. * L / 1680.;
|
||||||
|
|
||||||
|
local(1, 0) = -A * (-189.0) / 40.0 / L + B * (-57.0) / 80.0 + C * 33. * L / 560.;
|
||||||
|
local(1, 1) = -A * 54.0 / 5.0 / L + C * 27. * L / 70.;
|
||||||
|
local(1, 2) = -A * (-297.0) / 40.0 / L + B * 81.0 / 80.0 - C * 27. * L / 560.;
|
||||||
|
local(1, 3) = -A * 27.0 / 20.0 / L + B * (-3.0) / 10.0 - C * 3. * L / 140.;
|
||||||
|
|
||||||
|
local(2, 0) = -A * 27.0 / 20.0 / L + B * 3.0 / 10.0 - C * 3. * L / 140.;
|
||||||
|
local(2, 1) = -A * (-297.0) / 40.0 / L + B * (-81.0) / 80.0 - C * 27. * L / 560.;
|
||||||
|
local(2, 2) = -A * 54.0 / 5.0 / L + C * 27. * L / 70.;
|
||||||
|
local(2, 3) = -A * (-189.0) / 40.0 / L + B * 57.0 / 80.0 + C * 33. * L / 560.;
|
||||||
|
|
||||||
|
local(3, 0) = -A * (-13.0) / 40.0 / L + B * (-7.0) / 80.0 + C * 19. * L / 1680.;
|
||||||
|
local(3, 1) = -A * 27.0 / 20.0 / L + B * 3.0 / 10.0 - C * 3. * L / 140.;
|
||||||
|
local(3, 2) = -A * (-189.0) / 40.0 / L + B * (-57.0) / 80.0 + C * 33. * L / 560.;
|
||||||
|
local(3, 3) = -A * 37.0 / 10.0 / L + B * 1.0 / 2.0 + C * 8. * L / 105.;
|
||||||
|
|
||||||
|
// Локальный вектор нагрузки
|
||||||
|
local_load(0) = -D * L / 8.0;
|
||||||
|
local_load(1) = -D * 3.0 * L / 8.0;
|
||||||
|
local_load(2) = -D * 3.0 * L / 8.0;
|
||||||
|
local_load(3) = -D * L / 8.0;
|
||||||
|
|
||||||
|
// Глобальные матрицы
|
||||||
|
MatrixXd ansamb = MatrixXd::Zero(mat_dim, mat_dim);
|
||||||
|
VectorXd global_load = VectorXd::Zero(mat_dim);
|
||||||
|
|
||||||
|
// Ансамблирование (со смещением на 1, как в линейной версии)
|
||||||
|
for (int elem = 0; elem < N; ++elem) {
|
||||||
|
int node_i = 1 + elem * 3; // смещение на 1
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
for (int j = 0; j < 4; ++j) {
|
||||||
|
ansamb(node_i + i, node_i + j) += local(i, j);
|
||||||
|
}
|
||||||
|
global_load(node_i + i) += local_load(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
std::cout << std::endl << "Before:" << std::endl;
|
||||||
|
std::cout << "Ansamb matrix:\n" << ansamb << std::endl;
|
||||||
|
std::cout << "Ansamb load vector:\n" << global_load << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Граничные условия
|
||||||
|
double u_right = val2;
|
||||||
|
|
||||||
|
// 3rd type of boundary condition
|
||||||
|
ansamb.row(0).setZero();
|
||||||
|
ansamb(0, 0) = 1;
|
||||||
|
ansamb(0, 1) = -1;
|
||||||
|
global_load(0) = 0;
|
||||||
|
ansamb(1, 1) -= A;
|
||||||
|
|
||||||
|
// 1st type of boundary condition
|
||||||
|
for (int i = 0; i < global_load.size(); ++i) {
|
||||||
|
global_load(i) = global_load(i) - u_right * ansamb(i, mat_dim - 1);
|
||||||
|
}
|
||||||
|
ansamb.row(mat_dim - 1).setZero();
|
||||||
|
ansamb.col(mat_dim - 1).setZero();
|
||||||
|
ansamb(mat_dim - 1, mat_dim - 1) = 1;
|
||||||
|
global_load(mat_dim - 1) = u_right;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
std::cout << "\nAfter:" << std::endl;
|
||||||
|
std::cout << "Modified matrix:\n" << ansamb << std::endl;
|
||||||
|
std::cout << "Modified load vector:\n" << global_load << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Решение системы
|
||||||
|
VectorXd solution = ansamb.fullPivLu().solve(global_load);
|
||||||
|
std::cout << "\nSolution:" << std::endl;
|
||||||
|
std::cout << solution << std::endl;
|
||||||
|
|
||||||
|
std::ofstream file("matrix_cubic_" + std::to_string(N) + ".txt");
|
||||||
|
for (int i = 1; i < solution.size(); i++) {
|
||||||
|
file << solution(i) << ' ';
|
||||||
|
}
|
||||||
|
file << std::endl;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user